From afbb29cbfbaa479301a581ac66c5b75366e1c82b Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Mon, 17 Apr 2023 20:07:58 +0000 Subject: [PATCH 1/2] fix!: fix the HTTP format for merchant center link service PiperOrigin-RevId: 524889384 Source-Link: https://github.com/googleapis/googleapis/commit/5b42ea64776e51bfaa4bd49d2fe9b76bd678146c Source-Link: https://github.com/googleapis/googleapis-gen/commit/2aa53eb47e349b101e07d6e9321c746aa02418aa Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXJldGFpbC8uT3dsQm90LnlhbWwiLCJoIjoiMmFhNTNlYjQ3ZTM0OWIxMDFlMDdkNmU5MzIxYzc0NmFhMDI0MThhYSJ9 --- .../google-cloud-retail/v2/.eslintignore | 7 + .../google-cloud-retail/v2/.eslintrc.json | 3 + .../google-cloud-retail/v2/.gitignore | 14 + .../google-cloud-retail/v2/.jsdoc.js | 55 + .../google-cloud-retail/v2/.mocharc.js | 33 + .../google-cloud-retail/v2/.prettierrc.js | 22 + .../google-cloud-retail/v2/README.md | 1 + .../v2/linkinator.config.json | 16 + .../google-cloud-retail/v2/package.json | 72 + .../google/cloud/retail/v2/catalog.proto | 393 +++ .../cloud/retail/v2/catalog_service.proto | 476 +++ .../google/cloud/retail/v2/common.proto | 782 ++++ .../cloud/retail/v2/completion_service.proto | 220 ++ .../google/cloud/retail/v2/control.proto | 92 + .../cloud/retail/v2/control_service.proto | 185 + .../cloud/retail/v2/import_config.proto | 386 ++ .../protos/google/cloud/retail/v2/model.proto | 239 ++ .../cloud/retail/v2/model_service.proto | 262 ++ .../cloud/retail/v2/prediction_service.proto | 226 ++ .../google/cloud/retail/v2/product.proto | 586 +++ .../cloud/retail/v2/product_service.proto | 921 +++++ .../google/cloud/retail/v2/promotion.proto | 40 + .../google/cloud/retail/v2/purge_config.proto | 82 + .../cloud/retail/v2/search_service.proto | 985 ++++++ .../cloud/retail/v2/serving_config.proto | 265 ++ .../retail/v2/serving_config_service.proto | 240 ++ .../google/cloud/retail/v2/user_event.proto | 350 ++ .../cloud/retail/v2/user_event_service.proto | 210 ++ .../catalog_service.add_catalog_attribute.js | 68 + .../catalog_service.get_attributes_config.js | 62 + .../catalog_service.get_completion_config.js | 62 + .../v2/catalog_service.get_default_branch.js | 61 + .../v2/catalog_service.list_catalogs.js | 86 + ...atalog_service.remove_catalog_attribute.js | 68 + ...talog_service.replace_catalog_attribute.js | 76 + .../v2/catalog_service.set_default_branch.js | 84 + ...atalog_service.update_attributes_config.js | 70 + .../v2/catalog_service.update_catalog.js | 73 + ...atalog_service.update_completion_config.js | 78 + .../v2/completion_service.complete_query.js | 132 + ...mpletion_service.import_completion_data.js | 76 + .../v2/control_service.create_control.js | 75 + .../v2/control_service.delete_control.js | 62 + .../v2/control_service.get_control.js | 62 + .../v2/control_service.list_controls.js | 82 + .../v2/control_service.update_control.js | 69 + .../v2/model_service.create_model.js | 74 + .../v2/model_service.delete_model.js | 63 + .../generated/v2/model_service.get_model.js | 63 + .../generated/v2/model_service.list_models.js | 75 + .../generated/v2/model_service.pause_model.js | 63 + .../v2/model_service.resume_model.js | 63 + .../generated/v2/model_service.tune_model.js | 64 + .../v2/model_service.update_model.js | 66 + .../v2/prediction_service.predict.js | 187 + .../product_service.add_fulfillment_places.js | 119 + .../product_service.add_local_inventories.js | 102 + .../v2/product_service.create_product.js | 83 + .../v2/product_service.delete_product.js | 77 + .../v2/product_service.get_product.js | 68 + .../v2/product_service.import_products.js | 98 + .../v2/product_service.list_products.js | 133 + ...oduct_service.remove_fulfillment_places.js | 115 + ...roduct_service.remove_local_inventories.js | 88 + .../v2/product_service.set_inventory.js | 131 + .../v2/product_service.update_product.js | 87 + .../generated/v2/search_service.search.js | 312 ++ .../v2/serving_config_service.add_control.js | 68 + ...ng_config_service.create_serving_config.js | 75 + ...ng_config_service.delete_serving_config.js | 62 + ...rving_config_service.get_serving_config.js | 62 + ...ing_config_service.list_serving_configs.js | 75 + .../serving_config_service.remove_control.js | 68 + ...ng_config_service.update_serving_config.js | 69 + ...ippet_metadata.google.cloud.retail.v2.json | 2499 +++++++++++++ .../user_event_service.collect_user_event.js | 93 + .../user_event_service.import_user_events.js | 72 + .../user_event_service.purge_user_events.js | 93 + .../user_event_service.rejoin_user_events.js | 70 + .../v2/user_event_service.write_user_event.js | 74 + .../google-cloud-retail/v2/src/index.ts | 41 + .../v2/src/v2/catalog_service_client.ts | 2223 ++++++++++++ .../src/v2/catalog_service_client_config.json | 90 + .../v2/src/v2/catalog_service_proto_list.json | 21 + .../v2/src/v2/completion_service_client.ts | 1294 +++++++ .../v2/completion_service_client_config.json | 45 + .../src/v2/completion_service_proto_list.json | 21 + .../v2/src/v2/control_service_client.ts | 1556 ++++++++ .../src/v2/control_service_client_config.json | 46 + .../v2/src/v2/control_service_proto_list.json | 21 + .../v2/src/v2/gapic_metadata.json | 669 ++++ .../google-cloud-retail/v2/src/v2/index.ts | 27 + .../v2/src/v2/model_service_client.ts | 1811 ++++++++++ .../src/v2/model_service_client_config.json | 66 + .../v2/src/v2/model_service_proto_list.json | 21 + .../v2/src/v2/prediction_service_client.ts | 1226 +++++++ .../v2/prediction_service_client_config.json | 40 + .../src/v2/prediction_service_proto_list.json | 21 + .../v2/src/v2/product_service_client.ts | 2857 +++++++++++++++ .../src/v2/product_service_client_config.json | 99 + .../v2/src/v2/product_service_proto_list.json | 21 + .../v2/src/v2/search_service_client.ts | 2043 +++++++++++ .../src/v2/search_service_client_config.json | 40 + .../v2/src/v2/search_service_proto_list.json | 21 + .../src/v2/serving_config_service_client.ts | 1693 +++++++++ .../serving_config_service_client_config.json | 54 + .../v2/serving_config_service_proto_list.json | 21 + .../v2/src/v2/user_event_service_client.ts | 1559 ++++++++ .../v2/user_event_service_client_config.json | 78 + .../src/v2/user_event_service_proto_list.json | 21 + .../system-test/fixtures/sample/src/index.js | 35 + .../system-test/fixtures/sample/src/index.ts | 80 + .../v2/system-test/install.ts | 49 + .../v2/test/gapic_catalog_service_v2.ts | 2412 +++++++++++++ .../v2/test/gapic_completion_service_v2.ts | 1234 +++++++ .../v2/test/gapic_control_service_v2.ts | 1664 +++++++++ .../v2/test/gapic_model_service_v2.ts | 2096 +++++++++++ .../v2/test/gapic_prediction_service_v2.ts | 1064 ++++++ .../v2/test/gapic_product_service_v2.ts | 2662 ++++++++++++++ .../v2/test/gapic_search_service_v2.ts | 1336 +++++++ .../test/gapic_serving_config_service_v2.ts | 1880 ++++++++++ .../v2/test/gapic_user_event_service_v2.ts | 1650 +++++++++ .../google-cloud-retail/v2/tsconfig.json | 19 + .../google-cloud-retail/v2/webpack.config.js | 64 + .../google-cloud-retail/v2alpha/.eslintignore | 7 + .../v2alpha/.eslintrc.json | 3 + .../google-cloud-retail/v2alpha/.gitignore | 14 + .../google-cloud-retail/v2alpha/.jsdoc.js | 55 + .../google-cloud-retail/v2alpha/.mocharc.js | 33 + .../v2alpha/.prettierrc.js | 22 + .../google-cloud-retail/v2alpha/README.md | 1 + .../v2alpha/linkinator.config.json | 16 + .../google-cloud-retail/v2alpha/package.json | 73 + .../google/cloud/retail/v2alpha/catalog.proto | 477 +++ .../retail/v2alpha/catalog_service.proto | 527 +++ .../google/cloud/retail/v2alpha/common.proto | 794 +++++ .../retail/v2alpha/completion_service.proto | 255 ++ .../google/cloud/retail/v2alpha/control.proto | 100 + .../retail/v2alpha/control_service.proto | 185 + .../cloud/retail/v2alpha/export_config.proto | 107 + .../cloud/retail/v2alpha/import_config.proto | 408 +++ .../merchant_center_account_link.proto | 137 + ...merchant_center_account_link_service.proto | 140 + .../google/cloud/retail/v2alpha/model.proto | 451 +++ .../cloud/retail/v2alpha/model_service.proto | 263 ++ .../retail/v2alpha/prediction_service.proto | 226 ++ .../google/cloud/retail/v2alpha/product.proto | 598 ++++ .../retail/v2alpha/product_service.proto | 988 ++++++ .../cloud/retail/v2alpha/promotion.proto | 40 + .../cloud/retail/v2alpha/purge_config.proto | 174 + .../cloud/retail/v2alpha/search_service.proto | 1032 ++++++ .../cloud/retail/v2alpha/serving_config.proto | 281 ++ .../v2alpha/serving_config_service.proto | 241 ++ .../cloud/retail/v2alpha/user_event.proto | 354 ++ .../retail/v2alpha/user_event_service.proto | 210 ++ .../catalog_service.add_catalog_attribute.js | 68 + ...service.batch_remove_catalog_attributes.js | 70 + .../catalog_service.get_attributes_config.js | 62 + .../catalog_service.get_completion_config.js | 62 + .../catalog_service.get_default_branch.js | 61 + .../v2alpha/catalog_service.list_catalogs.js | 86 + ...atalog_service.remove_catalog_attribute.js | 68 + ...talog_service.replace_catalog_attribute.js | 76 + .../catalog_service.set_default_branch.js | 84 + ...atalog_service.update_attributes_config.js | 70 + .../v2alpha/catalog_service.update_catalog.js | 73 + ...atalog_service.update_completion_config.js | 78 + .../completion_service.complete_query.js | 137 + ...mpletion_service.import_completion_data.js | 76 + .../v2alpha/control_service.create_control.js | 75 + .../v2alpha/control_service.delete_control.js | 62 + .../v2alpha/control_service.get_control.js | 62 + .../v2alpha/control_service.list_controls.js | 82 + .../v2alpha/control_service.update_control.js | 69 + ...ice.create_merchant_center_account_link.js | 75 + ...ice.delete_merchant_center_account_link.js | 62 + ...vice.list_merchant_center_account_links.js | 63 + .../v2alpha/model_service.create_model.js | 74 + .../v2alpha/model_service.delete_model.js | 63 + .../v2alpha/model_service.get_model.js | 63 + .../v2alpha/model_service.list_models.js | 75 + .../v2alpha/model_service.pause_model.js | 63 + .../v2alpha/model_service.resume_model.js | 63 + .../v2alpha/model_service.tune_model.js | 64 + .../v2alpha/model_service.update_model.js | 67 + .../v2alpha/prediction_service.predict.js | 187 + .../product_service.add_fulfillment_places.js | 119 + .../product_service.add_local_inventories.js | 103 + .../v2alpha/product_service.create_product.js | 83 + .../v2alpha/product_service.delete_product.js | 89 + .../v2alpha/product_service.get_product.js | 68 + .../product_service.import_products.js | 107 + .../v2alpha/product_service.list_products.js | 144 + .../v2alpha/product_service.purge_products.js | 104 + ...oduct_service.remove_fulfillment_places.js | 115 + ...roduct_service.remove_local_inventories.js | 88 + .../v2alpha/product_service.set_inventory.js | 131 + .../v2alpha/product_service.update_product.js | 87 + .../v2alpha/search_service.search.js | 332 ++ .../serving_config_service.add_control.js | 68 + ...ng_config_service.create_serving_config.js | 75 + ...ng_config_service.delete_serving_config.js | 62 + ...rving_config_service.get_serving_config.js | 62 + ...ing_config_service.list_serving_configs.js | 75 + .../serving_config_service.remove_control.js | 68 + ...ng_config_service.update_serving_config.js | 69 + ..._metadata.google.cloud.retail.v2alpha.json | 2735 ++++++++++++++ .../user_event_service.collect_user_event.js | 93 + .../user_event_service.import_user_events.js | 72 + .../user_event_service.purge_user_events.js | 94 + .../user_event_service.rejoin_user_events.js | 70 + .../user_event_service.write_user_event.js | 74 + .../google-cloud-retail/v2alpha/src/index.ts | 43 + .../src/v2alpha/catalog_service_client.ts | 2369 +++++++++++++ .../catalog_service_client_config.json | 95 + .../v2alpha/catalog_service_proto_list.json | 24 + .../src/v2alpha/completion_service_client.ts | 1363 +++++++ .../completion_service_client_config.json | 45 + .../completion_service_proto_list.json | 24 + .../src/v2alpha/control_service_client.ts | 1621 +++++++++ .../control_service_client_config.json | 46 + .../v2alpha/control_service_proto_list.json | 24 + .../v2alpha/src/v2alpha/gapic_metadata.json | 733 ++++ .../v2alpha/src/v2alpha/index.ts | 28 + ...hant_center_account_link_service_client.ts | 1357 +++++++ ...er_account_link_service_client_config.json | 38 + ...enter_account_link_service_proto_list.json | 24 + .../src/v2alpha/model_service_client.ts | 1877 ++++++++++ .../v2alpha/model_service_client_config.json | 66 + .../src/v2alpha/model_service_proto_list.json | 24 + .../src/v2alpha/prediction_service_client.ts | 1291 +++++++ .../prediction_service_client_config.json | 40 + .../prediction_service_proto_list.json | 24 + .../src/v2alpha/product_service_client.ts | 3133 +++++++++++++++++ .../product_service_client_config.json | 104 + .../v2alpha/product_service_proto_list.json | 24 + .../src/v2alpha/search_service_client.ts | 2165 ++++++++++++ .../v2alpha/search_service_client_config.json | 40 + .../v2alpha/search_service_proto_list.json | 24 + .../v2alpha/serving_config_service_client.ts | 1759 +++++++++ .../serving_config_service_client_config.json | 54 + .../serving_config_service_proto_list.json | 24 + .../src/v2alpha/user_event_service_client.ts | 1625 +++++++++ .../user_event_service_client_config.json | 78 + .../user_event_service_proto_list.json | 24 + .../system-test/fixtures/sample/src/index.js | 36 + .../system-test/fixtures/sample/src/index.ts | 86 + .../v2alpha/system-test/install.ts | 49 + .../test/gapic_catalog_service_v2alpha.ts | 2574 ++++++++++++++ .../test/gapic_completion_service_v2alpha.ts | 1288 +++++++ .../test/gapic_control_service_v2alpha.ts | 1718 +++++++++ ...ant_center_account_link_service_v2alpha.ts | 1396 ++++++++ .../test/gapic_model_service_v2alpha.ts | 2150 +++++++++++ .../test/gapic_prediction_service_v2alpha.ts | 1118 ++++++ .../test/gapic_product_service_v2alpha.ts | 2870 +++++++++++++++ .../test/gapic_search_service_v2alpha.ts | 1390 ++++++++ .../gapic_serving_config_service_v2alpha.ts | 1934 ++++++++++ .../test/gapic_user_event_service_v2alpha.ts | 1704 +++++++++ .../google-cloud-retail/v2alpha/tsconfig.json | 19 + .../v2alpha/webpack.config.js | 64 + .../google-cloud-retail/v2beta/.eslintignore | 7 + .../google-cloud-retail/v2beta/.eslintrc.json | 3 + .../google-cloud-retail/v2beta/.gitignore | 14 + .../google-cloud-retail/v2beta/.jsdoc.js | 55 + .../google-cloud-retail/v2beta/.mocharc.js | 33 + .../google-cloud-retail/v2beta/.prettierrc.js | 22 + .../google-cloud-retail/v2beta/README.md | 1 + .../v2beta/linkinator.config.json | 16 + .../google-cloud-retail/v2beta/package.json | 72 + .../google/cloud/retail/v2beta/catalog.proto | 476 +++ .../cloud/retail/v2beta/catalog_service.proto | 527 +++ .../google/cloud/retail/v2beta/common.proto | 793 +++++ .../retail/v2beta/completion_service.proto | 220 ++ .../google/cloud/retail/v2beta/control.proto | 100 + .../cloud/retail/v2beta/control_service.proto | 185 + .../cloud/retail/v2beta/export_config.proto | 107 + .../cloud/retail/v2beta/import_config.proto | 386 ++ .../google/cloud/retail/v2beta/model.proto | 239 ++ .../cloud/retail/v2beta/model_service.proto | 263 ++ .../retail/v2beta/prediction_service.proto | 226 ++ .../google/cloud/retail/v2beta/product.proto | 597 ++++ .../cloud/retail/v2beta/product_service.proto | 925 +++++ .../cloud/retail/v2beta/promotion.proto | 40 + .../cloud/retail/v2beta/purge_config.proto | 83 + .../cloud/retail/v2beta/search_service.proto | 990 ++++++ .../cloud/retail/v2beta/serving_config.proto | 281 ++ .../v2beta/serving_config_service.proto | 240 ++ .../cloud/retail/v2beta/user_event.proto | 352 ++ .../retail/v2beta/user_event_service.proto | 210 ++ .../catalog_service.add_catalog_attribute.js | 68 + ...service.batch_remove_catalog_attributes.js | 70 + .../catalog_service.get_attributes_config.js | 62 + .../catalog_service.get_completion_config.js | 62 + .../catalog_service.get_default_branch.js | 61 + .../v2beta/catalog_service.list_catalogs.js | 86 + ...atalog_service.remove_catalog_attribute.js | 68 + ...talog_service.replace_catalog_attribute.js | 76 + .../catalog_service.set_default_branch.js | 84 + ...atalog_service.update_attributes_config.js | 70 + .../v2beta/catalog_service.update_catalog.js | 73 + ...atalog_service.update_completion_config.js | 78 + .../completion_service.complete_query.js | 132 + ...mpletion_service.import_completion_data.js | 76 + .../v2beta/control_service.create_control.js | 75 + .../v2beta/control_service.delete_control.js | 62 + .../v2beta/control_service.get_control.js | 62 + .../v2beta/control_service.list_controls.js | 82 + .../v2beta/control_service.update_control.js | 69 + .../v2beta/model_service.create_model.js | 74 + .../v2beta/model_service.delete_model.js | 63 + .../v2beta/model_service.get_model.js | 63 + .../v2beta/model_service.list_models.js | 75 + .../v2beta/model_service.pause_model.js | 63 + .../v2beta/model_service.resume_model.js | 63 + .../v2beta/model_service.tune_model.js | 64 + .../v2beta/model_service.update_model.js | 67 + .../v2beta/prediction_service.predict.js | 187 + .../product_service.add_fulfillment_places.js | 119 + .../product_service.add_local_inventories.js | 103 + .../v2beta/product_service.create_product.js | 83 + .../v2beta/product_service.delete_product.js | 78 + .../v2beta/product_service.get_product.js | 68 + .../v2beta/product_service.import_products.js | 98 + .../v2beta/product_service.list_products.js | 135 + ...oduct_service.remove_fulfillment_places.js | 115 + ...roduct_service.remove_local_inventories.js | 88 + .../v2beta/product_service.set_inventory.js | 131 + .../v2beta/product_service.update_product.js | 87 + .../generated/v2beta/search_service.search.js | 312 ++ .../serving_config_service.add_control.js | 68 + ...ng_config_service.create_serving_config.js | 75 + ...ng_config_service.delete_serving_config.js | 62 + ...rving_config_service.get_serving_config.js | 62 + ...ing_config_service.list_serving_configs.js | 75 + .../serving_config_service.remove_control.js | 68 + ...ng_config_service.update_serving_config.js | 69 + ...t_metadata.google.cloud.retail.v2beta.json | 2543 +++++++++++++ .../user_event_service.collect_user_event.js | 93 + .../user_event_service.import_user_events.js | 72 + .../user_event_service.purge_user_events.js | 94 + .../user_event_service.rejoin_user_events.js | 70 + .../user_event_service.write_user_event.js | 74 + .../google-cloud-retail/v2beta/src/index.ts | 41 + .../src/v2beta/catalog_service_client.ts | 2304 ++++++++++++ .../v2beta/catalog_service_client_config.json | 95 + .../v2beta/catalog_service_proto_list.json | 22 + .../src/v2beta/completion_service_client.ts | 1294 +++++++ .../completion_service_client_config.json | 45 + .../v2beta/completion_service_proto_list.json | 22 + .../src/v2beta/control_service_client.ts | 1556 ++++++++ .../v2beta/control_service_client_config.json | 46 + .../v2beta/control_service_proto_list.json | 22 + .../v2beta/src/v2beta/gapic_metadata.json | 679 ++++ .../v2beta/src/v2beta/index.ts | 27 + .../v2beta/src/v2beta/model_service_client.ts | 1812 ++++++++++ .../v2beta/model_service_client_config.json | 58 + .../src/v2beta/model_service_proto_list.json | 22 + .../src/v2beta/prediction_service_client.ts | 1226 +++++++ .../prediction_service_client_config.json | 40 + .../v2beta/prediction_service_proto_list.json | 22 + .../src/v2beta/product_service_client.ts | 2865 +++++++++++++++ .../v2beta/product_service_client_config.json | 99 + .../v2beta/product_service_proto_list.json | 22 + .../src/v2beta/search_service_client.ts | 2043 +++++++++++ .../v2beta/search_service_client_config.json | 40 + .../src/v2beta/search_service_proto_list.json | 22 + .../v2beta/serving_config_service_client.ts | 1693 +++++++++ .../serving_config_service_client_config.json | 54 + .../serving_config_service_proto_list.json | 22 + .../src/v2beta/user_event_service_client.ts | 1560 ++++++++ .../user_event_service_client_config.json | 78 + .../v2beta/user_event_service_proto_list.json | 22 + .../system-test/fixtures/sample/src/index.js | 35 + .../system-test/fixtures/sample/src/index.ts | 80 + .../v2beta/system-test/install.ts | 49 + .../test/gapic_catalog_service_v2beta.ts | 2520 +++++++++++++ .../test/gapic_completion_service_v2beta.ts | 1234 +++++++ .../test/gapic_control_service_v2beta.ts | 1664 +++++++++ .../v2beta/test/gapic_model_service_v2beta.ts | 2096 +++++++++++ .../test/gapic_prediction_service_v2beta.ts | 1064 ++++++ .../test/gapic_product_service_v2beta.ts | 2662 ++++++++++++++ .../test/gapic_search_service_v2beta.ts | 1336 +++++++ .../gapic_serving_config_service_v2beta.ts | 1880 ++++++++++ .../test/gapic_user_event_service_v2beta.ts | 1650 +++++++++ .../google-cloud-retail/v2beta/tsconfig.json | 19 + .../v2beta/webpack.config.js | 64 + 386 files changed, 151002 insertions(+) create mode 100644 owl-bot-staging/google-cloud-retail/v2/.eslintignore create mode 100644 owl-bot-staging/google-cloud-retail/v2/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-retail/v2/.gitignore create mode 100644 owl-bot-staging/google-cloud-retail/v2/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/README.md create mode 100644 owl-bot-staging/google-cloud-retail/v2/linkinator.config.json create mode 100644 owl-bot-staging/google-cloud-retail/v2/package.json create mode 100644 owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/catalog.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/catalog_service.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/common.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/completion_service.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/control.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/control_service.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/import_config.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/model.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/model_service.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/prediction_service.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/product.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/product_service.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/promotion.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/purge_config.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/search_service.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/serving_config.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/serving_config_service.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/user_event.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/user_event_service.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.add_catalog_attribute.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.get_attributes_config.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.get_completion_config.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.get_default_branch.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.list_catalogs.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.remove_catalog_attribute.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.replace_catalog_attribute.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.set_default_branch.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.update_attributes_config.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.update_catalog.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.update_completion_config.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/completion_service.complete_query.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/completion_service.import_completion_data.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/control_service.create_control.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/control_service.delete_control.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/control_service.get_control.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/control_service.list_controls.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/control_service.update_control.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.create_model.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.delete_model.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.get_model.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.list_models.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.pause_model.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.resume_model.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.tune_model.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.update_model.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/prediction_service.predict.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.add_fulfillment_places.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.add_local_inventories.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.create_product.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.delete_product.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.get_product.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.import_products.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.list_products.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.remove_fulfillment_places.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.remove_local_inventories.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.set_inventory.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.update_product.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/search_service.search.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/serving_config_service.add_control.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/serving_config_service.create_serving_config.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/serving_config_service.delete_serving_config.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/serving_config_service.get_serving_config.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/serving_config_service.list_serving_configs.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/serving_config_service.remove_control.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/serving_config_service.update_serving_config.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/snippet_metadata.google.cloud.retail.v2.json create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/user_event_service.collect_user_event.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/user_event_service.import_user_events.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/user_event_service.purge_user_events.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/user_event_service.rejoin_user_events.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/user_event_service.write_user_event.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/src/index.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/catalog_service_client.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/catalog_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/catalog_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/completion_service_client.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/completion_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/completion_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/control_service_client.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/control_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/control_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/index.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/model_service_client.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/model_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/model_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/prediction_service_client.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/prediction_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/prediction_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/product_service_client.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/product_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/product_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/search_service_client.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/search_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/search_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/serving_config_service_client.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/serving_config_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/serving_config_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/user_event_service_client.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/user_event_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/user_event_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-retail/v2/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-retail/v2/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2/test/gapic_catalog_service_v2.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2/test/gapic_completion_service_v2.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2/test/gapic_control_service_v2.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2/test/gapic_model_service_v2.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2/test/gapic_prediction_service_v2.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2/test/gapic_product_service_v2.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2/test/gapic_search_service_v2.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2/test/gapic_serving_config_service_v2.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2/test/gapic_user_event_service_v2.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-retail/v2/webpack.config.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/.eslintignore create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/.gitignore create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/README.md create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/linkinator.config.json create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/package.json create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/catalog.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/catalog_service.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/common.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/completion_service.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/control.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/control_service.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/export_config.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/import_config.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/merchant_center_account_link.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/merchant_center_account_link_service.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/model.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/model_service.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/prediction_service.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/product.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/product_service.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/promotion.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/purge_config.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/search_service.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/serving_config.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/serving_config_service.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/user_event.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/user_event_service.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.add_catalog_attribute.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.batch_remove_catalog_attributes.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.get_attributes_config.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.get_completion_config.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.get_default_branch.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.list_catalogs.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.remove_catalog_attribute.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.replace_catalog_attribute.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.set_default_branch.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.update_attributes_config.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.update_catalog.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.update_completion_config.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/completion_service.complete_query.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/completion_service.import_completion_data.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/control_service.create_control.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/control_service.delete_control.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/control_service.get_control.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/control_service.list_controls.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/control_service.update_control.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/merchant_center_account_link_service.create_merchant_center_account_link.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/merchant_center_account_link_service.delete_merchant_center_account_link.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/merchant_center_account_link_service.list_merchant_center_account_links.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.create_model.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.delete_model.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.get_model.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.list_models.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.pause_model.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.resume_model.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.tune_model.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.update_model.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/prediction_service.predict.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.add_fulfillment_places.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.add_local_inventories.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.create_product.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.delete_product.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.get_product.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.import_products.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.list_products.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.purge_products.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.remove_fulfillment_places.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.remove_local_inventories.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.set_inventory.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.update_product.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/search_service.search.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.add_control.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.create_serving_config.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.delete_serving_config.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.get_serving_config.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.list_serving_configs.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.remove_control.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.update_serving_config.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/snippet_metadata.google.cloud.retail.v2alpha.json create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/user_event_service.collect_user_event.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/user_event_service.import_user_events.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/user_event_service.purge_user_events.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/user_event_service.rejoin_user_events.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/user_event_service.write_user_event.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/index.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/catalog_service_client.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/catalog_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/catalog_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/completion_service_client.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/completion_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/completion_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/control_service_client.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/control_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/control_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/index.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/merchant_center_account_link_service_client.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/merchant_center_account_link_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/merchant_center_account_link_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/model_service_client.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/model_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/model_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/prediction_service_client.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/prediction_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/prediction_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/product_service_client.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/product_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/product_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/search_service_client.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/search_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/search_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/serving_config_service_client.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/serving_config_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/serving_config_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/user_event_service_client.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/user_event_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/user_event_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_catalog_service_v2alpha.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_completion_service_v2alpha.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_control_service_v2alpha.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_merchant_center_account_link_service_v2alpha.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_model_service_v2alpha.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_prediction_service_v2alpha.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_product_service_v2alpha.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_search_service_v2alpha.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_serving_config_service_v2alpha.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_user_event_service_v2alpha.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/webpack.config.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/.eslintignore create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/.eslintrc.json create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/.gitignore create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/.jsdoc.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/.mocharc.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/.prettierrc.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/README.md create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/linkinator.config.json create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/package.json create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/catalog.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/catalog_service.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/common.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/completion_service.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/control.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/control_service.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/export_config.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/import_config.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/model.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/model_service.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/prediction_service.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/product.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/product_service.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/promotion.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/purge_config.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/search_service.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/serving_config.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/serving_config_service.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/user_event.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/user_event_service.proto create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.add_catalog_attribute.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.batch_remove_catalog_attributes.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.get_attributes_config.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.get_completion_config.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.get_default_branch.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.list_catalogs.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.remove_catalog_attribute.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.replace_catalog_attribute.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.set_default_branch.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.update_attributes_config.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.update_catalog.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.update_completion_config.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/completion_service.complete_query.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/completion_service.import_completion_data.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/control_service.create_control.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/control_service.delete_control.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/control_service.get_control.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/control_service.list_controls.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/control_service.update_control.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.create_model.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.delete_model.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.get_model.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.list_models.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.pause_model.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.resume_model.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.tune_model.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.update_model.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/prediction_service.predict.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.add_fulfillment_places.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.add_local_inventories.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.create_product.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.delete_product.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.get_product.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.import_products.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.list_products.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.remove_fulfillment_places.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.remove_local_inventories.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.set_inventory.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.update_product.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/search_service.search.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.add_control.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.create_serving_config.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.delete_serving_config.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.get_serving_config.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.list_serving_configs.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.remove_control.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.update_serving_config.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/snippet_metadata.google.cloud.retail.v2beta.json create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/user_event_service.collect_user_event.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/user_event_service.import_user_events.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/user_event_service.purge_user_events.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/user_event_service.rejoin_user_events.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/user_event_service.write_user_event.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/index.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/catalog_service_client.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/catalog_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/catalog_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/completion_service_client.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/completion_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/completion_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/control_service_client.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/control_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/control_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/index.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/model_service_client.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/model_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/model_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/prediction_service_client.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/prediction_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/prediction_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/product_service_client.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/product_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/product_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/search_service_client.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/search_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/search_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/serving_config_service_client.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/serving_config_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/serving_config_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/user_event_service_client.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/user_event_service_client_config.json create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/user_event_service_proto_list.json create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/system-test/install.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/test/gapic_catalog_service_v2beta.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/test/gapic_completion_service_v2beta.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/test/gapic_control_service_v2beta.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/test/gapic_model_service_v2beta.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/test/gapic_prediction_service_v2beta.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/test/gapic_product_service_v2beta.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/test/gapic_search_service_v2beta.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/test/gapic_serving_config_service_v2beta.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/test/gapic_user_event_service_v2beta.ts create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/tsconfig.json create mode 100644 owl-bot-staging/google-cloud-retail/v2beta/webpack.config.js diff --git a/owl-bot-staging/google-cloud-retail/v2/.eslintignore b/owl-bot-staging/google-cloud-retail/v2/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-retail/v2/.eslintrc.json b/owl-bot-staging/google-cloud-retail/v2/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-retail/v2/.gitignore b/owl-bot-staging/google-cloud-retail/v2/.gitignore new file mode 100644 index 00000000000..d4f03a0df2e --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2/.jsdoc.js b/owl-bot-staging/google-cloud-retail/v2/.jsdoc.js new file mode 100644 index 00000000000..66e9db869e8 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 2023 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/retail', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-retail/v2/.mocharc.js b/owl-bot-staging/google-cloud-retail/v2/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/.mocharc.js @@ -0,0 +1,33 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +const config = { + "enable-source-maps": true, + "throw-deprecation": true, + "timeout": 10000 +} +if (process.env.MOCHA_THROW_DEPRECATION === 'false') { + delete config['throw-deprecation']; +} +if (process.env.MOCHA_REPORTER) { + config.reporter = process.env.MOCHA_REPORTER; +} +if (process.env.MOCHA_REPORTER_OUTPUT) { + config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; +} +module.exports = config diff --git a/owl-bot-staging/google-cloud-retail/v2/.prettierrc.js b/owl-bot-staging/google-cloud-retail/v2/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/.prettierrc.js @@ -0,0 +1,22 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/owl-bot-staging/google-cloud-retail/v2/README.md b/owl-bot-staging/google-cloud-retail/v2/README.md new file mode 100644 index 00000000000..822c4573817 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/README.md @@ -0,0 +1 @@ +Retail: Nodejs Client diff --git a/owl-bot-staging/google-cloud-retail/v2/linkinator.config.json b/owl-bot-staging/google-cloud-retail/v2/linkinator.config.json new file mode 100644 index 00000000000..befd23c8633 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2/package.json b/owl-bot-staging/google-cloud-retail/v2/package.json new file mode 100644 index 00000000000..468da5696b6 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/package.json @@ -0,0 +1,72 @@ +{ + "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", + "model service", + "prediction service", + "product service", + "search service", + "serving config service", + "user event service" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^3.5.7" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.1", + "jsdoc": "^4.0.0", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.1", + "linkinator": "^4.1.2", + "mocha": "^10.2.0", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.0.1", + "ts-loader": "^8.4.0", + "typescript": "^4.8.4", + "webpack": "^4.46.0", + "webpack-cli": "^4.10.0" + }, + "engines": { + "node": ">=v12" + } +} diff --git a/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/catalog.proto b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/catalog.proto new file mode 100644 index 00000000000..4205e00147e --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/catalog.proto @@ -0,0 +1,393 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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/import_config.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "cloud.google.com/go/retail/apiv2/retailpb;retailpb"; +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; +} + +// 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.v2.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. + 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. + 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. + SEARCHABLE_OPTION_UNSPECIFIED = 0; + + // Searchable option enabled for an attribute. + SEARCHABLE_ENABLED = 1; + + // Searchable option disabled for an attribute. + SEARCHABLE_DISABLED = 2; + } + + // The status of the exact-searchable option of a catalog attribute. + enum ExactSearchableOption { + // Value used when unset. + EXACT_SEARCHABLE_OPTION_UNSPECIFIED = 0; + + // Exact searchable option enabled for an attribute. + EXACT_SEARCHABLE_ENABLED = 1; + + // Exact searchable option disabled for an attribute. + EXACT_SEARCHABLE_DISABLED = 2; + } + + // The status of the retrievable option of a catalog attribute. + enum RetrievableOption { + // Value used when unset. + RETRIEVABLE_OPTION_UNSPECIFIED = 0; + + // Retrievable option enabled for an attribute. + RETRIEVABLE_ENABLED = 1; + + // Retrievable option disabled for an attribute. + RETRIEVABLE_DISABLED = 2; + } + + // Required. Attribute name. + // For example: `color`, `brands`, `attributes.custom_attribute`, such as + // `attributes.xyz`. + // To be indexable, the attribute name can contain only alpha-numeric + // characters and underscores. For example, an attribute named + // `attributes.abc_xyz` can be indexed, but an attribute named + // `attributes.abc-xyz` cannot be indexed. + // + // If the attribute key starts with `attributes.`, then the attribute is a + // custom attribute. Attributes such as `brands`, `patterns`, and `title` are + // built-in and called system attributes. + 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.v2.Product] + // is using this attribute in + // [Product.attributes][google.cloud.retail.v2.Product.attributes]. Otherwise, + // this field is `False`. + // + // [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] can be + // pre-loaded by using + // [CatalogService.AddCatalogAttribute][google.cloud.retail.v2.CatalogService.AddCatalogAttribute], + // [CatalogService.ImportCatalogAttributes][], or + // [CatalogService.UpdateAttributesConfig][google.cloud.retail.v2.CatalogService.UpdateAttributesConfig] + // APIs. This field is `False` for pre-loaded + // [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute]s. + // + // Only pre-loaded [catalog + // attributes][google.cloud.retail.v2.CatalogAttribute] that are neither in + // use by products nor predefined can be deleted. [Catalog + // attributes][google.cloud.retail.v2.CatalogAttribute] that are + // either in use by products or are predefined attributes 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.v2.Product.attributes]. + AttributeType type = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // When + // [AttributesConfig.attribute_config_level][google.cloud.retail.v2.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.v2.SearchService.Search]. + // + // Must be specified, otherwise throws INVALID_FORMAT error. + 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.v2.CatalogAttribute.indexable_option] + // is INDEXABLE_DISABLED. Otherwise, an INVALID_ARGUMENT error is returned. + // + // Must be specified, otherwise throws INVALID_FORMAT error. + DynamicFacetableOption dynamic_facetable_option = 6; + + // When + // [AttributesConfig.attribute_config_level][google.cloud.retail.v2.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.v2.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.v2.SearchService.Search], as + // there are no text values associated to numerical attributes. + // + // Must be specified, otherwise throws INVALID_FORMAT error. + SearchableOption searchable_option = 7; + + // If EXACT_SEARCHABLE_ENABLED, attribute values will be exact searchable. + // This property only applies to textual custom attributes and requires + // indexable set to enabled to enable exact-searchable. If unset, the server + // behavior defaults to + // [EXACT_SEARCHABLE_DISABLED][google.cloud.retail.v2.CatalogAttribute.ExactSearchableOption.EXACT_SEARCHABLE_DISABLED]. + ExactSearchableOption exact_searchable_option = 11; + + // If RETRIEVABLE_ENABLED, attribute values are retrievable in the search + // results. If unset, the server behavior defaults to + // [RETRIEVABLE_DISABLED][google.cloud.retail.v2.CatalogAttribute.RetrievableOption.RETRIEVABLE_DISABLED]. + RetrievableOption retrievable_option = 12; +} + +// 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.v2.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. Default + // value is 20. If left unset or set to 0, then will fallback to default + // value. + // + // Value range is 1 to 20. + 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. + // + // Value range is 1 to 20. + 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.v2.CompleteQueryRequest]. + bool auto_learning = 11; + + // Output only. The source data for the latest import of the autocomplete + // suggestion phrases. + 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 source data for the latest import of the autocomplete + // denylist phrases. + CompletionDataInputConfig denylist_input_config = 7 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Name of the 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 source data for the latest import of the autocomplete + // allowlist phrases. + CompletionDataInputConfig allowlist_input_config = 9 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Name of the 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]; +} + +// 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/google-cloud-retail/v2/protos/google/cloud/retail/v2/catalog_service.proto b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/catalog_service.proto new file mode 100644 index 00000000000..14b45841baa --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/catalog_service.proto @@ -0,0 +1,476 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 = "cloud.google.com/go/retail/apiv2/retailpb;retailpb"; +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"; + } + + // Gets a [CompletionConfig][google.cloud.retail.v2.CompletionConfig]. + rpc GetCompletionConfig(GetCompletionConfigRequest) + returns (CompletionConfig) { + option (google.api.http) = { + get: "/v2/{name=projects/*/locations/*/catalogs/*/completionConfig}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates the [CompletionConfig][google.cloud.retail.v2.CompletionConfig]s. + rpc UpdateCompletionConfig(UpdateCompletionConfigRequest) + returns (CompletionConfig) { + option (google.api.http) = { + patch: "/v2/{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.v2.AttributesConfig]. + rpc GetAttributesConfig(GetAttributesConfigRequest) + returns (AttributesConfig) { + option (google.api.http) = { + get: "/v2/{name=projects/*/locations/*/catalogs/*/attributesConfig}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates the [AttributesConfig][google.cloud.retail.v2.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: "/v2/{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.v2.CatalogAttribute] to the + // [AttributesConfig][google.cloud.retail.v2.AttributesConfig]. + // + // If the [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] to add + // already exists, an ALREADY_EXISTS error is returned. + rpc AddCatalogAttribute(AddCatalogAttributeRequest) + returns (AttributesConfig) { + option (google.api.http) = { + post: "/v2/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:addCatalogAttribute" + body: "*" + }; + } + + // Removes the specified + // [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] from the + // [AttributesConfig][google.cloud.retail.v2.AttributesConfig]. + // + // If the [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] to + // remove does not exist, a NOT_FOUND error is returned. + rpc RemoveCatalogAttribute(RemoveCatalogAttributeRequest) + returns (AttributesConfig) { + option (google.api.http) = { + post: "/v2/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:removeCatalogAttribute" + body: "*" + }; + } + + // Replaces the specified + // [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] in the + // [AttributesConfig][google.cloud.retail.v2.AttributesConfig] by updating the + // catalog attribute with the same + // [CatalogAttribute.key][google.cloud.retail.v2.CatalogAttribute.key]. + // + // If the [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] to + // replace does not exist, a NOT_FOUND error is returned. + rpc ReplaceCatalogAttribute(ReplaceCatalogAttributeRequest) + returns (AttributesConfig) { + option (google.api.http) = { + post: "/v2/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:replaceCatalogAttribute" + body: "*" + }; + } +} + +// 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; +} + +// Request for +// [CatalogService.GetCompletionConfig][google.cloud.retail.v2.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.v2.CatalogService.UpdateCompletionConfig] +// method. +message UpdateCompletionConfigRequest { + // Required. The [CompletionConfig][google.cloud.retail.v2.CompletionConfig] + // to update. + // + // If the caller does not have permission to update the + // [CompletionConfig][google.cloud.retail.v2.CompletionConfig], then a + // PERMISSION_DENIED error is returned. + // + // If the [CompletionConfig][google.cloud.retail.v2.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.v2.CompletionConfig] to update. The + // following are the only supported fields: + // + // * [CompletionConfig.matching_order][google.cloud.retail.v2.CompletionConfig.matching_order] + // * [CompletionConfig.max_suggestions][google.cloud.retail.v2.CompletionConfig.max_suggestions] + // * [CompletionConfig.min_prefix_length][google.cloud.retail.v2.CompletionConfig.min_prefix_length] + // * [CompletionConfig.auto_learning][google.cloud.retail.v2.CompletionConfig.auto_learning] + // + // If not set, all supported fields are updated. + google.protobuf.FieldMask update_mask = 2; +} + +// Request for +// [CatalogService.GetAttributesConfig][google.cloud.retail.v2.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.v2.CatalogService.UpdateAttributesConfig] +// method. +message UpdateAttributesConfigRequest { + // Required. The [AttributesConfig][google.cloud.retail.v2.AttributesConfig] + // to update. + AttributesConfig attributes_config = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [AttributesConfig][google.cloud.retail.v2.AttributesConfig] to update. The + // following is the only supported field: + // + // * [AttributesConfig.catalog_attributes][google.cloud.retail.v2.AttributesConfig.catalog_attributes] + // + // If not set, all supported fields are updated. + google.protobuf.FieldMask update_mask = 2; +} + +// Request for +// [CatalogService.AddCatalogAttribute][google.cloud.retail.v2.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.v2.CatalogAttribute] + // to add. + CatalogAttribute catalog_attribute = 2 + [(google.api.field_behavior) = REQUIRED]; +} + +// Request for +// [CatalogService.RemoveCatalogAttribute][google.cloud.retail.v2.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.v2.CatalogAttribute] to remove. + string key = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for +// [CatalogService.ReplaceCatalogAttribute][google.cloud.retail.v2.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.v2.CatalogAttribute]. + CatalogAttribute catalog_attribute = 2 + [(google.api.field_behavior) = REQUIRED]; + + // Indicates which fields in the provided + // [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] to update. The + // following are NOT supported: + // + // * [CatalogAttribute.key][google.cloud.retail.v2.CatalogAttribute.key] + // + // If not set, all supported fields are updated. + google.protobuf.FieldMask update_mask = 3; +} diff --git a/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/common.proto b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/common.proto new file mode 100644 index 00000000000..d04afc3d178 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/common.proto @@ -0,0 +1,782 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 = "cloud.google.com/go/retail/apiv2/retailpb;retailpb"; +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"; + +// At which level we offer configuration for attributes. +enum AttributeConfigLevel { + // Value used when unset. In this case, server behavior defaults to + // [CATALOG_LEVEL_ATTRIBUTE_CONFIG][google.cloud.retail.v2.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.v2.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; +} + +// If filtering for recommendations is enabled. +enum RecommendationsFilteringOption { + // Value used when unset. + // In this case, server behavior defaults to + // [RECOMMENDATIONS_FILTERING_DISABLED][google.cloud.retail.v2.RecommendationsFilteringOption.RECOMMENDATIONS_FILTERING_DISABLED]. + RECOMMENDATIONS_FILTERING_OPTION_UNSPECIFIED = 0; + + // Recommendation filtering is disabled. + RECOMMENDATIONS_FILTERING_DISABLED = 1; + + // Recommendation filtering is enabled. + RECOMMENDATIONS_FILTERING_ENABLED = 3; +} + +// The use case of Cloud Retail Search. +enum SearchSolutionUseCase { + // The value when it's unspecified. In this case, server behavior defaults to + // [SEARCH_SOLUTION_USE_CASE_SEARCH][google.cloud.retail.v2.SearchSolutionUseCase.SEARCH_SOLUTION_USE_CASE_SEARCH]. + SEARCH_SOLUTION_USE_CASE_UNSPECIFIED = 0; + + // Search use case. Expects the traffic has a non-empty + // [query][google.cloud.retail.v2.SearchRequest.query]. + SEARCH_SOLUTION_USE_CASE_SEARCH = 1; + + // Browse use case. Expects the traffic has an empty + // [query][google.cloud.retail.v2.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. + // For example, "a b c" is 3 terms and allowed, but " a b c d" is 4 terms + // and not allowed for a 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 rules only work for [controls][google.cloud.retail.v2.Control] with +// [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2.SolutionType.SOLUTION_TYPE_SEARCH]. +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.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 products_filter = 2; + } + + // * Rule Condition: + // - No + // [Condition.query_terms][google.cloud.retail.v2.Condition.query_terms] + // provided is a global match. + // - 1 or more + // [Condition.query_terms][google.cloud.retail.v2.Condition.query_terms] + // provided are combined with OR operator. + // * Action Input: The request query and filter that are 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.v2.Rule.FilterAction.filter] must be set. + // * Filter syntax is identical to + // [SearchRequest.filter][google.cloud.retail.v2.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][google.cloud.retail.v2.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.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 75 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][google.cloud.retail.v2.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][google.cloud.retail.v2.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 not be larger than 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. + // 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/google-cloud-retail/v2/protos/google/cloud/retail/v2/completion_service.proto b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/completion_service.proto new file mode 100644 index 00000000000..75c2d93710e --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/completion_service.proto @@ -0,0 +1,220 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 = "cloud.google.com/go/retail/apiv2/retailpb;retailpb"; +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"; + +// Autocomplete service for retail. +// +// This feature is only available for users who have Retail Search enabled. +// 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. + // 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. + // 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" + }; + } +} + +// Autocomplete 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; + + // Note that this field applies for `user-data` dataset only. For requests + // with `cloud-retail` dataset, setting this field has no effect. + // + // 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. We recommend that you + // leave this field empty. + // + // It can 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][google.cloud.retail.v2.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; + + // The entity for customers that may run multiple different entities, domains, + // sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, + // `google.com`, `youtube.com`, etc. + // If this is set, it should be exactly matched with + // [UserEvent.entity][google.cloud.retail.v2.UserEvent.entity] to get + // per-entity autocomplete results. + string entity = 10; +} + +// Response of the autocomplete 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. It requires + // [UserEvent.product_details][google.cloud.retail.v2.UserEvent.product_details] + // is imported properly. + 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 case. + // + // * 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/google-cloud-retail/v2/protos/google/cloud/retail/v2/control.proto b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/control.proto new file mode 100644 index 00000000000..c2b1d1c9d79 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/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.v2; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/retail/v2/common.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "cloud.google.com/go/retail/apiv2/retailpb;retailpb"; +option java_multiple_files = true; +option java_outer_classname = "ControlProto"; +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 dynamic metadata that can be linked to a +// [ServingConfig][google.cloud.retail.v2.ServingConfig] and affect search or +// recommendation results at serving time. +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 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 config][google.cloud.retail.v2.ServingConfig] + // ids that are associated with this control in the same + // [Catalog][google.cloud.retail.v2.Catalog]. + // + // Note the association is managed via the + // [ServingConfig][google.cloud.retail.v2.ServingConfig], this is an output + // only denormalized view. + repeated string associated_serving_config_ids = 5 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Required. Immutable. The solution types that the control 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][google.cloud.retail.v2.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated SolutionType solution_types = 6 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; + + // 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][google.cloud.retail.v2.SearchSolutionUseCase.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; +} diff --git a/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/control_service.proto b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/control_service.proto new file mode 100644 index 00000000000..e84e30b2167 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/control_service.proto @@ -0,0 +1,185 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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/control.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "cloud.google.com/go/retail/apiv2/retailpb;retailpb"; +option java_multiple_files = true; +option java_outer_classname = "ControlServiceProto"; +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 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.v2.Control] to create already exists, + // an ALREADY_EXISTS error is returned. + rpc CreateControl(CreateControlRequest) returns (Control) { + option (google.api.http) = { + post: "/v2/{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.v2.Control] to delete does not exist, + // a NOT_FOUND error is returned. + rpc DeleteControl(DeleteControlRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v2/{name=projects/*/locations/*/catalogs/*/controls/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates a Control. + // + // [Control][google.cloud.retail.v2.Control] cannot be set to a different + // oneof field, if so an INVALID_ARGUMENT is returned. If the + // [Control][google.cloud.retail.v2.Control] to update does not exist, a + // NOT_FOUND error is returned. + rpc UpdateControl(UpdateControlRequest) returns (Control) { + option (google.api.http) = { + patch: "/v2/{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: "/v2/{name=projects/*/locations/*/catalogs/*/controls/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists all Controls by their parent + // [Catalog][google.cloud.retail.v2.Catalog]. + rpc ListControls(ListControlsRequest) returns (ListControlsResponse) { + option (google.api.http) = { + get: "/v2/{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.v2.Control] to update. The following are NOT + // supported: + // + // * [Control.name][google.cloud.retail.v2.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 get. 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.v2.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/google-cloud-retail/v2/protos/google/cloud/retail/v2/import_config.proto b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/import_config.proto new file mode 100644 index 00000000000..f6ff762a37b --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/import_config.proto @@ -0,0 +1,386 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 = "cloud.google.com/go/retail/apiv2/retailpb;retailpb"; +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. +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][google.cloud.retail.v2.Control] + // per line. + // + // Supported values for catalog attribute imports: + // + // * `catalog_attribute` (default): One CSV + // [CatalogAttribute][google.cloud.retail.v2.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 in + // [ImportProductsRequest][google.cloud.retail.v2.ImportProductsRequest]. + 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`: + // The schema is available here: + // https://support.google.com/analytics/answer/7029846. + // + // Supported values for autocomplete 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 are 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. + 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, all fields are updated. + 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 is sent to + // specified Pub/Sub topic. The message data is 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 `service-@gcp-sa-retail.iam.gserviceaccount.com` has the + // `pubsub.topics.publish` IAM permission on the topic. + 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 is sent to + // specified Pub/Sub topic. The message data is 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 is +// 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 is sent to + // specified Pub/Sub topic. The message data is 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/google-cloud-retail/v2/protos/google/cloud/retail/v2/model.proto b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/model.proto new file mode 100644 index 00000000000..85b64fcea52 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/model.proto @@ -0,0 +1,239 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "cloud.google.com/go/retail/apiv2/retailpb;retailpb"; +option java_multiple_files = true; +option java_outer_classname = "ModelProto"; +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 that describes the training and serving parameters of a +// [Model][google.cloud.retail.v2.Model]. A +// [Model][google.cloud.retail.v2.Model] can be associated with a +// [ServingConfig][google.cloud.retail.v2.ServingConfig] and then queried +// through the Predict API. +message Model { + option (google.api.resource) = { + type: "retail.googleapis.com/Model" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}" + }; + + // Represents an ordered combination of valid serving configs, which + // can be used for `PAGE_OPTIMIZATION` recommendations. + message ServingConfigList { + // Optional. A set of valid serving configs that may be used for + // `PAGE_OPTIMIZATION`. + repeated string serving_config_ids = 1 + [(google.api.field_behavior) = OPTIONAL]; + } + + // The serving state of the model. + enum ServingState { + // Unspecified serving state. + SERVING_STATE_UNSPECIFIED = 0; + + // The model is not serving. + INACTIVE = 1; + + // The model is serving and can be queried. + ACTIVE = 2; + + // The model is trained on tuned hyperparameters and can be + // queried. + TUNED = 3; + } + + // The training state of the model. + enum TrainingState { + // Unspecified training state. + TRAINING_STATE_UNSPECIFIED = 0; + + // The model training is paused. + PAUSED = 1; + + // The model is training. + TRAINING = 2; + } + + // Describes whether periodic tuning is enabled for this model + // or not. Periodic tuning is scheduled at most every three months. You can + // start a tuning process manually by using the `TuneModel` + // method, which starts a tuning process immediately and resets the quarterly + // schedule. Enabling or disabling periodic tuning does not affect any + // current tuning processes. + enum PeriodicTuningState { + // Unspecified default value, should never be explicitly set. + PERIODIC_TUNING_STATE_UNSPECIFIED = 0; + + // The model has periodic tuning disabled. Tuning + // can be reenabled by calling the `EnableModelPeriodicTuning` + // method or by calling the `TuneModel` method. + PERIODIC_TUNING_DISABLED = 1; + + // The model cannot be tuned with periodic tuning OR the + // `TuneModel` method. Hide the options in customer UI and + // reject any requests through the backend self serve API. + ALL_TUNING_DISABLED = 3; + + // The model has periodic tuning enabled. Tuning + // can be disabled by calling the `DisableModelPeriodicTuning` + // method. + PERIODIC_TUNING_ENABLED = 2; + } + + // Describes whether this model have sufficient training data + // to be continuously trained. + enum DataState { + // Unspecified default value, should never be explicitly set. + DATA_STATE_UNSPECIFIED = 0; + + // The model has sufficient training data. + DATA_OK = 1; + + // The model does not have sufficient training data. Error + // messages can be queried via Stackdriver. + DATA_ERROR = 2; + } + + // Required. The fully qualified resource name of the model. + // + // Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + // catalog_id has char limit of 50. + // recommendation_model_id has char limit of 40. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The display name of the model. + // + // Should be human readable, used to display Recommendation Models in the + // Retail Cloud Console Dashboard. UTF-8 encoded string with limit of 1024 + // characters. + string display_name = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. The training state that the model is in (e.g. + // `TRAINING` or `PAUSED`). + // + // Since part of the cost of running the service + // is frequency of training - this can be used to determine when to train + // model in order to control cost. If not specified: the default value for + // `CreateModel` method is `TRAINING`. The default value for + // `UpdateModel` method is to keep the state the same as before. + TrainingState training_state = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. The serving state of the model: `ACTIVE`, `NOT_ACTIVE`. + ServingState serving_state = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Timestamp the Recommendation Model was created at. + google.protobuf.Timestamp create_time = 5 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Timestamp the Recommendation Model was last updated. E.g. + // if a Recommendation Model was paused - this would be the time the pause was + // initiated. + google.protobuf.Timestamp update_time = 6 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Required. The type of model e.g. `home-page`. + // + // Currently supported values: `recommended-for-you`, `others-you-may-like`, + // `frequently-bought-together`, `page-optimization`, `similar-items`, + // `buy-it-again`, `on-sale-items`, and `recently-viewed`(readonly value). + // + // + // This field together with + // [optimization_objective][google.cloud.retail.v2.Model.optimization_objective] + // describe model metadata to use to control model training and serving. + // See https://cloud.google.com/retail/docs/models + // for more details on what the model metadata control and which combination + // of parameters are valid. For invalid combinations of parameters (e.g. type + // = `frequently-bought-together` and optimization_objective = `ctr`), you + // receive an error 400 if you try to create/update a recommendation with + // this set of knobs. + string type = 7 [(google.api.field_behavior) = REQUIRED]; + + // Optional. The optimization objective e.g. `cvr`. + // + // Currently supported + // values: `ctr`, `cvr`, `revenue-per-order`. + // + // If not specified, we choose default based on model type. + // Default depends on type of recommendation: + // + // `recommended-for-you` => `ctr` + // + // `others-you-may-like` => `ctr` + // + // `frequently-bought-together` => `revenue_per_order` + // + // This field together with + // [optimization_objective][google.cloud.retail.v2.Model.type] + // describe model metadata to use to control model training and serving. + // See https://cloud.google.com/retail/docs/models + // for more details on what the model metadata control and which combination + // of parameters are valid. For invalid combinations of parameters (e.g. type + // = `frequently-bought-together` and optimization_objective = `ctr`), you + // receive an error 400 if you try to create/update a recommendation with + // this set of knobs. + string optimization_objective = 8 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The state of periodic tuning. + // + // The period we use is 3 months - to do a + // one-off tune earlier use the `TuneModel` method. Default value + // is `PERIODIC_TUNING_ENABLED`. + PeriodicTuningState periodic_tuning_state = 11 + [(google.api.field_behavior) = OPTIONAL]; + + // Output only. The timestamp when the latest successful tune finished. + google.protobuf.Timestamp last_tune_time = 12 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The tune operation associated with the model. + // + // Can be used to determine if there is an ongoing tune for this + // recommendation. Empty field implies no tune is goig on. + string tuning_operation = 15 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The state of data requirements for this model: `DATA_OK` and + // `DATA_ERROR`. + // + // Recommendation model cannot be trained if the data is in + // `DATA_ERROR` state. Recommendation model can have `DATA_ERROR` state even + // if serving state is `ACTIVE`: models were trained successfully before, but + // cannot be refreshed because model no longer has sufficient + // data for training. + DataState data_state = 16 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. If `RECOMMENDATIONS_FILTERING_ENABLED`, recommendation filtering + // by attributes is enabled for the model. + RecommendationsFilteringOption filtering_option = 18 + [(google.api.field_behavior) = OPTIONAL]; + + // Output only. The list of valid serving configs associated with the + // PageOptimizationConfig. + repeated ServingConfigList serving_config_lists = 19 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/model_service.proto b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/model_service.proto new file mode 100644 index 00000000000..488cf8d74e1 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/model_service.proto @@ -0,0 +1,262 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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/model.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "cloud.google.com/go/retail/apiv2/retailpb;retailpb"; +option java_multiple_files = true; +option java_outer_classname = "ModelServiceProto"; +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 performing CRUD operations on models. +// Recommendation models contain all the metadata necessary to generate a set of +// models for the `Predict()` API. A model is queried +// indirectly via a ServingConfig, which associates a model with a +// given Placement (e.g. Frequently Bought Together on Home Page). +// +// This service allows you to do the following: +// +// * Initiate training of a model. +// * Pause training of an existing model. +// * List all the available models along with their metadata. +// * Control their tuning schedule. +service ModelService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Creates a new model. + rpc CreateModel(CreateModelRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{parent=projects/*/locations/*/catalogs/*}/models" + body: "model" + }; + option (google.api.method_signature) = "parent,model"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2.Model" + metadata_type: "google.cloud.retail.v2.CreateModelMetadata" + }; + } + + // Gets a model. + rpc GetModel(GetModelRequest) returns (Model) { + option (google.api.http) = { + get: "/v2/{name=projects/*/locations/*/catalogs/*/models/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Pauses the training of an existing model. + rpc PauseModel(PauseModelRequest) returns (Model) { + option (google.api.http) = { + post: "/v2/{name=projects/*/locations/*/catalogs/*/models/*}:pause" + body: "*" + }; + option (google.api.method_signature) = "name"; + } + + // Resumes the training of an existing model. + rpc ResumeModel(ResumeModelRequest) returns (Model) { + option (google.api.http) = { + post: "/v2/{name=projects/*/locations/*/catalogs/*/models/*}:resume" + body: "*" + }; + option (google.api.method_signature) = "name"; + } + + // Deletes an existing model. + rpc DeleteModel(DeleteModelRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v2/{name=projects/*/locations/*/catalogs/*/models/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists all the models linked to this event store. + rpc ListModels(ListModelsRequest) returns (ListModelsResponse) { + option (google.api.http) = { + get: "/v2/{parent=projects/*/locations/*/catalogs/*}/models" + }; + option (google.api.method_signature) = "parent"; + } + + // Update of model metadata. Only fields that + // currently can be updated are: `filtering_option` and + // `periodic_tuning_state`. + // If other values are provided, this API method ignores them. + rpc UpdateModel(UpdateModelRequest) returns (Model) { + option (google.api.http) = { + patch: "/v2/{model.name=projects/*/locations/*/catalogs/*/models/*}" + body: "model" + }; + option (google.api.method_signature) = "model,update_mask"; + } + + // Tunes an existing model. + rpc TuneModel(TuneModelRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2/{name=projects/*/locations/*/catalogs/*/models/*}:tune" + body: "*" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2.TuneModelResponse" + metadata_type: "google.cloud.retail.v2.TuneModelMetadata" + }; + } +} + +// Request for creating a model. +message CreateModelRequest { + // Required. The parent resource under which to create the model. 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 payload of the [Model][google.cloud.retail.v2.Model] to + // create. + Model model = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Whether to run a dry run to validate the request (without + // actually creating the model). + bool dry_run = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Request for updating an existing model. +message UpdateModelRequest { + // Required. The body of the updated [Model][google.cloud.retail.v2.Model]. + Model model = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Indicates which fields in the provided 'model' to + // update. If not set, by default updates all fields. + google.protobuf.FieldMask update_mask = 2 + [(google.api.field_behavior) = OPTIONAL]; +} + +// Request for getting a model. +message GetModelRequest { + // Required. The resource name of the [Model][google.cloud.retail.v2.Model] to + // get. Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog}/models/{model_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Model" } + ]; +} + +// Request for pausing training of a model. +message PauseModelRequest { + // Required. The name of the model to pause. + // Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Model" } + ]; +} + +// Request for resuming training of a model. +message ResumeModelRequest { + // Required. The name of the model to resume. + // Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for listing models associated with a resource. +message ListModelsRequest { + // Required. The parent for which to list models. + // 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 `ListModels` + // call. Provide this to retrieve the subsequent page. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Request for deleting a model. +message DeleteModelRequest { + // Required. The resource name of the [Model][google.cloud.retail.v2.Model] to + // delete. Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Model" } + ]; +} + +// Response to a ListModelRequest. +message ListModelsResponse { + // List of Models. + repeated Model models = 1; + + // Pagination token, if not returned indicates the last page. + string next_page_token = 2; +} + +// Request to manually start a tuning process now (instead of waiting for +// the periodically scheduled tuning to happen). +message TuneModelRequest { + // Required. The resource name of the model to tune. + // Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Model" } + ]; +} + +// Metadata associated with a create operation. +message CreateModelMetadata { + // The resource name of the model that this create applies to. + // Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + string model = 1; +} + +// Metadata associated with a tune operation. +message TuneModelMetadata { + // The resource name of the model that this tune applies to. + // Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + string model = 1; +} + +// Response associated with a tune operation. +message TuneModelResponse {} diff --git a/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/prediction_service.proto b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/prediction_service.proto new file mode 100644 index 00000000000..6e8061726ca --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/prediction_service.proto @@ -0,0 +1,226 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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/user_event.proto"; +import "google/protobuf/struct.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "cloud.google.com/go/retail/apiv2/retailpb;retailpb"; +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: "*" + additional_bindings { + post: "/v2/{placement=projects/*/locations/*/catalogs/*/servingConfigs/*}:predict" + body: "*" + } + }; + } +} + +// Request message for Predict method. +message PredictRequest { + // Required. Full resource name of the format: + // `{placement=projects/*/locations/global/catalogs/default_catalog/servingConfigs/*}` + // or + // `{placement=projects/*/locations/global/catalogs/default_catalog/placements/*}`. + // We recommend using the `servingConfigs` resource. `placements` is a legacy + // resource. + // The ID of the Recommendations AI serving config or placement. + // Before you can request predictions from your model, you must create at + // least one serving config or placement for it. For more information, see + // [Manage serving configs] + // (https://cloud.google.com/retail/docs/manage-configs). + // + // The full list of available serving configs can be seen at + // https://console.cloud.google.com/ai/retail/catalogs/default_catalog/configs + 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. 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; + + // This field is not used; leave it unset. + string page_token = 4 [deprecated = true]; + + // 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 *no* + // results. If instead you want empty result sets to return generic + // (unfiltered) popular products, set `strictFiltering` to False in + // `PredictRequest.params`. Note that the API will never return items with + // storageStatus of "EXPIRED" or "DELETED" regardless of filter choices. + // + // If `filterSyntaxV2` is set to true under the `params` field, then + // attribute-based expressions are expected instead of the above described + // tag-based syntax. Examples: + // + // * (colors: ANY("Red", "Blue")) AND NOT (categories: ANY("Phones")) + // * (availability: ANY("IN_STOCK")) AND + // (colors: ANY("Red") OR categories: ANY("Phones")) + // + // For more information, see + // [Filter recommendations](https://cloud.google.com/retail/docs/filter-recs). + 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 a 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. + // * `filterSyntaxV2`: Boolean. False by default. If set to true, the `filter` + // field is interpreteted according to the new, attribute-based syntax. + 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/google-cloud-retail/v2/protos/google/cloud/retail/v2/product.proto b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/product.proto new file mode 100644 index 00000000000..f1ec4869508 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/product.proto @@ -0,0 +1,586 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 = "cloud.google.com/go/retail/apiv2/retailpb;retailpb"; +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]. Note + // that this is only applicable to + // [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] and + // [Type.COLLECTION][google.cloud.retail.v2.Product.Type.COLLECTION], and + // ignored for [Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT]. + // In general, we suggest the users to delete the stale products explicitly, + // instead of using this field to determine staleness. + // + // 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. Note that this is only + // applicable to [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] + // and [Type.COLLECTION][google.cloud.retail.v2.Product.Type.COLLECTION], + // and ignored for + // [Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT]. In general, + // we suggest the users to delete the stale products explicitly, instead of + // using this field to determine staleness. + // + // 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 an + // 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, 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]. Note + // that this is only applicable to + // [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] and + // [Type.COLLECTION][google.cloud.retail.v2.Product.Type.COLLECTION], and + // ignored for [Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT]. + 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. + // + // This field is deprecated. Use the retrievable site-wide control instead. + google.protobuf.FieldMask retrievable_fields = 30 [deprecated = true]; + + // 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]; + + // Output only. A list of local inventories specific to different places. + // + // This field can be managed by + // [ProductService.AddLocalInventories][google.cloud.retail.v2.ProductService.AddLocalInventories] + // and + // [ProductService.RemoveLocalInventories][google.cloud.retail.v2.ProductService.RemoveLocalInventories] + // APIs if fine-grained, high-volume updates are necessary. + repeated LocalInventory local_inventories = 35 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/product_service.proto b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/product_service.proto new file mode 100644 index 00000000000..ff69b68c7b4 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/product_service.proto @@ -0,0 +1,921 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 = "cloud.google.com/go/retail/apiv2/retailpb;retailpb"; +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 is 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 + // [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] + // or + // [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. + // + // When inventory is updated with + // [ProductService.CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] + // and + // [ProductService.UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct], + // the specified inventory field value(s) overwrite any existing value(s) + // while ignoring the last update time for this field. Furthermore, the last + // update times for the specified inventory fields are overwritten by the + // times of the + // [ProductService.CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] + // or + // [ProductService.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 is used. + // + // If no inventory fields are set in + // [SetInventoryRequest.set_mask][google.cloud.retail.v2.SetInventoryRequest.set_mask], + // then any existing inventory information is preserved. + // + // Pre-existing inventory information can only be updated with + // [ProductService.SetInventory][google.cloud.retail.v2.ProductService.SetInventory], + // [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2.ProductService.AddFulfillmentPlaces], + // and + // [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces]. + // + // The returned [Operation][google.longrunning.Operation]s is obsolete after + // one day, and the [GetOperation][google.longrunning.Operations.GetOperation] + // API returns `NOT_FOUND` afterwards. + // + // If conflicting updates are issued, the + // [Operation][google.longrunning.Operation]s associated with the stale + // updates are not marked as [done][google.longrunning.Operation.done] until + // they are obsolete. + 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" + }; + } + + // It is recommended to use the + // [ProductService.AddLocalInventories][google.cloud.retail.v2.ProductService.AddLocalInventories] + // method instead of + // [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2.ProductService.AddFulfillmentPlaces]. + // [ProductService.AddLocalInventories][google.cloud.retail.v2.ProductService.AddLocalInventories] + // achieves the same results but provides more fine-grained control over + // ingesting local inventory data. + // + // 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 + // [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] + // or + // [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. + // + // The returned [Operation][google.longrunning.Operation]s will be obsolete + // after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] + // API will return NOT_FOUND afterwards. + // + // If conflicting updates are issued, the + // [Operation][google.longrunning.Operation]s associated with the stale + // updates will not be marked as [done][google.longrunning.Operation.done] + // until being obsolete. + 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" + }; + } + + // It is recommended to use the + // [ProductService.RemoveLocalInventories][google.cloud.retail.v2.ProductService.RemoveLocalInventories] + // method instead of + // [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces]. + // [ProductService.RemoveLocalInventories][google.cloud.retail.v2.ProductService.RemoveLocalInventories] + // achieves the same results but provides more fine-grained control over + // ingesting local inventory data. + // + // 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 + // [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] + // or + // [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. + // + // The returned [Operation][google.longrunning.Operation]s will be obsolete + // after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] + // API will return NOT_FOUND afterwards. + // + // If conflicting updates are issued, the + // [Operation][google.longrunning.Operation]s associated with the stale + // updates will not be marked as [done][google.longrunning.Operation.done] + // until being obsolete. + 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 + // [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] + // or + // [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. + // + // Local inventory information can only be modified using this method. + // [ProductService.CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] + // and + // [ProductService.UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] + // has no effect on local inventories. + // + // The returned [Operation][google.longrunning.Operation]s will be obsolete + // after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] + // API will return NOT_FOUND afterwards. + // + // If conflicting updates are issued, the + // [Operation][google.longrunning.Operation]s associated with the stale + // updates will not be marked as [done][google.longrunning.Operation.done] + // until being obsolete. + 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 + // [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] + // or + // [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. + // + // Local inventory information can only be removed using this method. + // [ProductService.CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] + // and + // [ProductService.UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] + // has no effect on local inventories. + // + // The returned [Operation][google.longrunning.Operation]s will be obsolete + // after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] + // API will return NOT_FOUND afterwards. + // + // If conflicting updates are issued, the + // [Operation][google.longrunning.Operation]s associated with the stale + // updates will not be marked as [done][google.longrunning.Operation.done] + // until being obsolete. + 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 +// [ProductService.CreateProduct][google.cloud.retail.v2.ProductService.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 +// [ProductService.GetProduct][google.cloud.retail.v2.ProductService.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 +// [ProductService.UpdateProduct][google.cloud.retail.v2.ProductService.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 +// [ProductService.DeleteProduct][google.cloud.retail.v2.ProductService.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 +// [ProductService.SetInventory][google.cloud.retail.v2.ProductService.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][google.cloud.retail.v2.Product.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][google.cloud.retail.v2.Product.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][google.cloud.retail.v2.Product.fulfillment_info] + // * Checks that only the desired fulfillment info types have empty + // [SetInventoryRequest.inventory.fulfillment_info.place_ids][google.cloud.retail.v2.FulfillmentInfo.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, + // [ProductService.UpdateProduct][google.cloud.retail.v2.ProductService.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 +// [ProductService.SetInventory][google.cloud.retail.v2.ProductService.SetInventory] +// method. +message SetInventoryMetadata {} + +// Response of the SetInventoryRequest. Currently empty because +// there is no meaningful response populated from the +// [ProductService.SetInventory][google.cloud.retail.v2.ProductService.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][google.cloud.retail.v2.FulfillmentInfo.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 +// [ProductService.RemoveLocalInventories][google.cloud.retail.v2.ProductService.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 +// [ProductService.RemoveLocalInventories][google.cloud.retail.v2.ProductService.RemoveLocalInventories] +// method. +message RemoveLocalInventoriesMetadata {} + +// Response of the +// [ProductService.RemoveLocalInventories][google.cloud.retail.v2.ProductService.RemoveLocalInventories] +// API. Currently empty because there is no meaningful response populated from +// the +// [ProductService.RemoveLocalInventories][google.cloud.retail.v2.ProductService.RemoveLocalInventories] +// method. +message RemoveLocalInventoriesResponse {} + +// Request message for +// [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2.ProductService.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 +// [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces] +// method. +message RemoveFulfillmentPlacesMetadata {} + +// Response of the RemoveFulfillmentPlacesRequest. Currently empty because there +// is no meaningful response populated from the +// [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces] +// method. +message RemoveFulfillmentPlacesResponse {} diff --git a/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/promotion.proto b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/promotion.proto new file mode 100644 index 00000000000..26694384515 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/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 = "cloud.google.com/go/retail/apiv2/retailpb;retailpb"; +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/google-cloud-retail/v2/protos/google/cloud/retail/v2/purge_config.proto b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/purge_config.proto new file mode 100644 index 00000000000..fe6272d5d9d --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/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 = "cloud.google.com/go/retail/apiv2/retailpb;retailpb"; +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/google-cloud-retail/v2/protos/google/cloud/retail/v2/search_service.proto b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/search_service.proto new file mode 100644 index 00000000000..d25d2849970 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/search_service.proto @@ -0,0 +1,985 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 = "cloud.google.com/go/retail/apiv2/retailpb;retailpb"; +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"; +option (google.api.resource_definition) = { + type: "retail.googleapis.com/Experiment" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/experiments/{experiment}" +}; + +// Service for search. +// +// This feature is only available for users who have Retail Search enabled. +// 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. + // 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: "*" + additional_bindings { + post: "/v2/{placement=projects/*/locations/*/catalogs/*/servingConfigs/*}: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 40. + // + // For all numerical facet keys that appear in the list of products from + // the catalog, the percentiles 0, 10, 30, 50, 70, 90 and 100 are + // computed from their distribution weekly. If the model assigns a high + // score to a numerical facet key and its intervals are not specified in + // the search request, these percentiles will become the bounds + // for its intervals and will be returned in the response. If the + // facet key intervals are specified in the request, then the specified + // intervals will be returned instead. + 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; + + // True to make facet keys case insensitive when getting faceting + // values with prefixes or contains; false otherwise. + bool case_insensitive = 10; + + // The order in which + // [SearchResponse.Facet.values][google.cloud.retail.v2.SearchResponse.Facet.values] + // are returned. + // + // Allowed values are: + // + // * "count desc", which means order by + // [SearchResponse.Facet.values.count][google.cloud.retail.v2.SearchResponse.Facet.FacetValue.count] + // descending. + // + // * "value desc", which means order by + // [SearchResponse.Facet.values.value][google.cloud.retail.v2.SearchResponse.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, + // [SearchResponse.Facet.values.value][google.cloud.retail.v2.SearchResponse.Facet.FacetValue.value] + // will be always "1" and + // [SearchResponse.Facet.values.count][google.cloud.retail.v2.SearchResponse.Facet.FacetValue.count] + // will be the number of results that match 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; + + // Returns the min and max value for each numerical facet intervals. + // Ignored for textual facets. + bool return_min_max = 11; + } + + // 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 50. 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. In this case, server behavior + // 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. In this case, server behavior defaults to + // [Mode.AUTO][google.cloud.retail.v2.SearchRequest.PersonalizationSpec.Mode.AUTO]. + MODE_UNSPECIFIED = 0; + + // Let CRS decide whether to use personalization based on quality of user + // event data. + 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. In this case, server behavior + // 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][google.cloud.retail.v2.SearchResponse.SearchResult] + // and [SearchResponse.Facet][google.cloud.retail.v2.SearchResponse.Facet] + // will be returned. + SEARCH_MODE_UNSPECIFIED = 0; + + // Only product search will be performed. The faceted search will be + // disabled. + // + // Only + // [SearchResponse.SearchResult][google.cloud.retail.v2.SearchResponse.SearchResult] + // will be returned. + // [SearchResponse.Facet][google.cloud.retail.v2.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][google.cloud.retail.v2.SearchResponse.Facet] will + // be returned. + // [SearchResponse.SearchResult][google.cloud.retail.v2.SearchResponse.SearchResult] + // will not be returned. + FACETED_SEARCH_ONLY = 2; + } + + // Required. The resource name of the Retail Search serving config, such as + // `projects/*/locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` + // or the name of the legacy placement resource, such as + // `projects/*/locations/global/catalogs/default_catalog/placements/default_search`. + // This field is used to identify the serving config 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 200 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.v2.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, 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. + // + // Notice that if both + // [ServingConfig.personalization_spec][google.cloud.retail.v2.ServingConfig.personalization_spec] + // and + // [SearchRequest.personalization_spec][google.cloud.retail.v2.SearchRequest.personalization_spec] + // are set. + // [SearchRequest.personalization_spec][google.cloud.retail.v2.SearchRequest.personalization_spec] + // will override + // [ServingConfig.personalization_spec][google.cloud.retail.v2.ServingConfig.personalization_spec]. + 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; + + // The entity for customers that may run multiple different entities, domains, + // sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, + // `google.com`, `youtube.com`, etc. + // If this is set, it should be exactly matched with + // [UserEvent.entity][google.cloud.retail.v2.UserEvent.entity] to get search + // results boosted by entity. + string entity = 38; +} + +// 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; + + // Specifies previous events related to this product for this user based on + // [UserEvent][google.cloud.retail.v2.UserEvent] with same + // [SearchRequest.visitor_id][google.cloud.retail.v2.SearchRequest.visitor_id] + // or [UserInfo.user_id][google.cloud.retail.v2.UserInfo.user_id]. + // + // This is set only when + // [SearchRequest.PersonalizationSpec.mode][google.cloud.retail.v2.SearchRequest.PersonalizationSpec.mode] + // is + // [SearchRequest.PersonalizationSpec.Mode.AUTO][google.cloud.retail.v2.SearchRequest.PersonalizationSpec.Mode.AUTO]. + // + // Possible values: + // + // * `purchased`: Indicates that this product has been purchased before. + repeated string personal_labels = 7; + } + + // 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 minimum value in the + // [FacetValue.interval][google.cloud.retail.v2.SearchResponse.Facet.FacetValue.interval]. + // Only supported on numerical facets and returned if + // [SearchRequest.FacetSpec.FacetKey.return_min_max][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.return_min_max] + // is true. + double min_value = 5; + + // The maximum value in the + // [FacetValue.interval][google.cloud.retail.v2.SearchResponse.Facet.FacetValue.interval]. + // Only supported on numerical facets and returned if + // [SearchRequest.FacetSpec.FacetKey.return_min_max][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.return_min_max] + // is true. + double max_value = 6; + } + + // 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 is 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; + + // Metadata related to A/B testing [Experiment][] associated with this + // response. Only exists when an experiment is triggered. + repeated ExperimentInfo experiment_info = 17; +} + +// Metadata for active A/B testing [Experiments][]. +message ExperimentInfo { + // Metadata for active serving config A/B tests. + message ServingConfigExperiment { + // The fully qualified resource name of the original + // [SearchRequest.placement][google.cloud.retail.v2.SearchRequest.placement] + // in the search request prior to reassignment by experiment API. For + // example: `projects/*/locations/*/catalogs/*/servingConfigs/*`. + string original_serving_config = 1 [(google.api.resource_reference) = { + type: "retail.googleapis.com/ServingConfig" + }]; + + // The fully qualified resource name of the serving config + // [VariantArm.serving_config_id][] responsible for generating the search + // response. For example: + // `projects/*/locations/*/catalogs/*/servingConfigs/*`. + string experiment_serving_config = 2 [(google.api.resource_reference) = { + type: "retail.googleapis.com/ServingConfig" + }]; + } + + // Information associated with the specific experiment entity being recorded. + oneof experiment_metadata { + // A/B test between existing Cloud Retail Search + // [ServingConfig][google.cloud.retail.v2.ServingConfig]s. + ServingConfigExperiment serving_config_experiment = 2; + } + + // The fully qualified resource name of the experiment that provides the + // serving config under test, should an active experiment exist. For example: + // `projects/*/locations/global/catalogs/default_catalog/experiments/experiment_id` + string experiment = 1 [(google.api.resource_reference) = { + type: "retail.googleapis.com/Experiment" + }]; +} diff --git a/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/serving_config.proto b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/serving_config.proto new file mode 100644 index 00000000000..ef5b46fca2b --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/serving_config.proto @@ -0,0 +1,265 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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/search_service.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "cloud.google.com/go/retail/apiv2/retailpb;retailpb"; +option java_multiple_files = true; +option java_outer_classname = "ServingConfigProto"; +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 metadata that is used to generate serving time results (e.g. +// search results or recommendation predictions). +message ServingConfig { + option (google.api.resource) = { + type: "retail.googleapis.com/ServingConfig" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}" + }; + + // What type of diversity - data or rule based. + enum DiversityType { + // Default value. + DIVERSITY_TYPE_UNSPECIFIED = 0; + + // Rule based diversity. + RULE_BASED_DIVERSITY = 2; + + // Data driven diversity. + DATA_DRIVEN_DIVERSITY = 3; + } + + // 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 in the same [Catalog][google.cloud.retail.v2.Catalog] + // 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.v2.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-reranking` + // * `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.v2.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.v2.Control] + // resources with only the Facet control set. These controls are assumed to be + // in the same [Catalog][google.cloud.retail.v2.Catalog] as the + // [ServingConfig][google.cloud.retail.v2.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.v2.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.v2.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.v2.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. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2.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.v2.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.v2.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.v2.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.v2.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.v2.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.v2.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.v2.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.v2.ServingConfig.solution_types] is + // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. + string diversity_level = 8; + + // What kind of diversity to use - data driven or rule based. If unset, the + // server behavior defaults to + // [RULE_BASED_DIVERSITY][google.cloud.retail.v2.ServingConfig.DiversityType.RULE_BASED_DIVERSITY]. + DiversityType diversity_type = 20; + + // 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.v2.ServingConfig.solution_types] is + // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. + string enable_category_filter_level = 16; + + // The specification for personalization spec. + // + // Can only be set if + // [solution_types][google.cloud.retail.v2.ServingConfig.solution_types] is + // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. + // + // Notice that if both + // [ServingConfig.personalization_spec][google.cloud.retail.v2.ServingConfig.personalization_spec] + // and + // [SearchRequest.personalization_spec][google.cloud.retail.v2.SearchRequest.personalization_spec] + // are set. + // [SearchRequest.personalization_spec][google.cloud.retail.v2.SearchRequest.personalization_spec] + // will override + // [ServingConfig.personalization_spec][google.cloud.retail.v2.ServingConfig.personalization_spec]. + SearchRequest.PersonalizationSpec personalization_spec = 21; + + // 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/google-cloud-retail/v2/protos/google/cloud/retail/v2/serving_config_service.proto b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/serving_config_service.proto new file mode 100644 index 00000000000..25ca897f306 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/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.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/serving_config.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2"; +option go_package = "cloud.google.com/go/retail/apiv2/retailpb;retailpb"; +option java_multiple_files = true; +option java_outer_classname = "ServingConfigServiceProto"; +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 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.v2.ServingConfig]s are + // allowed in a [Catalog][google.cloud.retail.v2.Catalog], otherwise a + // FAILED_PRECONDITION error is returned. + rpc CreateServingConfig(CreateServingConfigRequest) returns (ServingConfig) { + option (google.api.http) = { + post: "/v2/{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: "/v2/{name=projects/*/locations/*/catalogs/*/servingConfigs/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates a ServingConfig. + rpc UpdateServingConfig(UpdateServingConfigRequest) returns (ServingConfig) { + option (google.api.http) = { + patch: "/v2/{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: "/v2/{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: "/v2/{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: "/v2/{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: "/v2/{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.v2.ServingConfig] to update. The + // following are NOT supported: + // + // * [ServingConfig.name][google.cloud.retail.v2.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/google-cloud-retail/v2/protos/google/cloud/retail/v2/user_event.proto b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/user_event.proto new file mode 100644 index 00000000000..1ddc8bd6178 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/user_event.proto @@ -0,0 +1,350 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 = "cloud.google.com/go/retail/apiv2/retailpb;retailpb"; +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, 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; + + // The entity for customers that may run multiple different entities, domains, + // sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, + // `google.com`, `youtube.com`, etc. + // It is recommended to set this field to get better per-entity search, + // completion and prediction results. + string entity = 23; +} + +// 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/google-cloud-retail/v2/protos/google/cloud/retail/v2/user_event_service.proto b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/user_event_service.proto new file mode 100644 index 00000000000..719fdaa2d43 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/user_event_service.proto @@ -0,0 +1,210 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 = "cloud.google.com/go/retail/apiv2/retailpb;retailpb"; +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 + // are not annotated with detailed product information for products that are + // missing from the catalog when the user event is ingested. These + // events are stored as unjoined events with limited usage on training and + // serving. You can use this method to start a join operation on specified + // events with the latest version of product catalog. You can also use this + // method 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]; + + // If set to true, the user event will be written asynchronously after + // validation, and the API will respond without waiting for the write. + // Therefore, silent failures can occur even if the API returns success. In + // case of silent failures, error messages can be found in Stackdriver logs. + bool write_async = 3; +} + +// Request message for CollectUserEvent method. +message CollectUserEventRequest { + // The rule that can convert the raw_json to a user event. It is needed + // only when the raw_json is set. + oneof conversion_rule { + // The prebuilt rule name that can convert a specific type of raw_json. + // For example: "ga4_bq" rule for the GA4 user event schema. + string prebuilt_rule = 6; + } + + // 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; + + // An arbitrary serialized JSON string that contains necessary information + // that can comprise a user event. When this field is specified, the + // user_event field will be ignored. Note: line-delimited JSON is not + // supported, a single JSON only. + string raw_json = 5; +} + +// 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/google-cloud-retail/v2/samples/generated/v2/catalog_service.add_catalog_attribute.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.add_catalog_attribute.js new file mode 100644 index 00000000000..fb7a8fe38d5 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.add_catalog_attribute.js @@ -0,0 +1,68 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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_v2_generated_CatalogService_AddCatalogAttribute_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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.v2.CatalogAttribute + * to add. + */ + // const catalogAttribute = {} + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2; + + // 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_v2_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/google-cloud-retail/v2/samples/generated/v2/catalog_service.get_attributes_config.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.get_attributes_config.js new file mode 100644 index 00000000000..fa8e639ec77 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.get_attributes_config.js @@ -0,0 +1,62 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by 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_CatalogService_GetAttributesConfig_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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').v2; + + // 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_v2_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/google-cloud-retail/v2/samples/generated/v2/catalog_service.get_completion_config.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.get_completion_config.js new file mode 100644 index 00000000000..c5bc650ded5 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.get_completion_config.js @@ -0,0 +1,62 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by 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_CatalogService_GetCompletionConfig_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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').v2; + + // 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_v2_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/google-cloud-retail/v2/samples/generated/v2/catalog_service.get_default_branch.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.get_default_branch.js new file mode 100644 index 00000000000..04e61acded0 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.get_default_branch.js @@ -0,0 +1,61 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2/samples/generated/v2/catalog_service.list_catalogs.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.list_catalogs.js new file mode 100644 index 00000000000..74c743460e8 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.list_catalogs.js @@ -0,0 +1,86 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2/samples/generated/v2/catalog_service.remove_catalog_attribute.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.remove_catalog_attribute.js new file mode 100644 index 00000000000..295f155f0b9 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.remove_catalog_attribute.js @@ -0,0 +1,68 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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_v2_generated_CatalogService_RemoveCatalogAttribute_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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.v2.CatalogAttribute to remove. + */ + // const key = 'abc123' + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2; + + // 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_v2_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/google-cloud-retail/v2/samples/generated/v2/catalog_service.replace_catalog_attribute.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.replace_catalog_attribute.js new file mode 100644 index 00000000000..623955dd3f7 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.replace_catalog_attribute.js @@ -0,0 +1,76 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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_v2_generated_CatalogService_ReplaceCatalogAttribute_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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.v2.CatalogAttribute. + */ + // const catalogAttribute = {} + /** + * Indicates which fields in the provided + * CatalogAttribute google.cloud.retail.v2.CatalogAttribute to update. The + * following are NOT supported: + * * CatalogAttribute.key google.cloud.retail.v2.CatalogAttribute.key + * If not set, all supported fields are updated. + */ + // const updateMask = {} + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2; + + // 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_v2_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/google-cloud-retail/v2/samples/generated/v2/catalog_service.set_default_branch.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.set_default_branch.js new file mode 100644 index 00000000000..f1919ac27e9 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.set_default_branch.js @@ -0,0 +1,84 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2/samples/generated/v2/catalog_service.update_attributes_config.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.update_attributes_config.js new file mode 100644 index 00000000000..a4ce6ca300d --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.update_attributes_config.js @@ -0,0 +1,70 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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_v2_generated_CatalogService_UpdateAttributesConfig_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The AttributesConfig google.cloud.retail.v2.AttributesConfig + * to update. + */ + // const attributesConfig = {} + /** + * Indicates which fields in the provided + * AttributesConfig google.cloud.retail.v2.AttributesConfig to update. The + * following is the only supported field: + * * AttributesConfig.catalog_attributes google.cloud.retail.v2.AttributesConfig.catalog_attributes + * If not set, all supported fields are updated. + */ + // const updateMask = {} + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2; + + // 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_v2_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/google-cloud-retail/v2/samples/generated/v2/catalog_service.update_catalog.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.update_catalog.js new file mode 100644 index 00000000000..731c8e4846c --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.update_catalog.js @@ -0,0 +1,73 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2/samples/generated/v2/catalog_service.update_completion_config.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.update_completion_config.js new file mode 100644 index 00000000000..9e8591755ed --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.update_completion_config.js @@ -0,0 +1,78 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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_v2_generated_CatalogService_UpdateCompletionConfig_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The CompletionConfig google.cloud.retail.v2.CompletionConfig + * to update. + * If the caller does not have permission to update the + * CompletionConfig google.cloud.retail.v2.CompletionConfig, then a + * PERMISSION_DENIED error is returned. + * If the CompletionConfig google.cloud.retail.v2.CompletionConfig to + * update does not exist, a NOT_FOUND error is returned. + */ + // const completionConfig = {} + /** + * Indicates which fields in the provided + * CompletionConfig google.cloud.retail.v2.CompletionConfig to update. The + * following are the only supported fields: + * * CompletionConfig.matching_order google.cloud.retail.v2.CompletionConfig.matching_order + * * CompletionConfig.max_suggestions google.cloud.retail.v2.CompletionConfig.max_suggestions + * * CompletionConfig.min_prefix_length google.cloud.retail.v2.CompletionConfig.min_prefix_length + * * CompletionConfig.auto_learning google.cloud.retail.v2.CompletionConfig.auto_learning + * If not set, all supported fields are updated. + */ + // const updateMask = {} + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2; + + // 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_v2_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/google-cloud-retail/v2/samples/generated/v2/completion_service.complete_query.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/completion_service.complete_query.js new file mode 100644 index 00000000000..e9c66ec9520 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/completion_service.complete_query.js @@ -0,0 +1,132 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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' + /** + * Note that this field applies for `user-data` dataset only. For requests + * with `cloud-retail` dataset, setting this field has no effect. + * 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. We recommend that you + * leave this field empty. + * It can 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 google.cloud.retail.v2.CompletionConfig.max_suggestions. + * The maximum allowed max suggestions is 20. If it is set higher, it will be + * capped by 20. + */ + // const maxSuggestions = 1234 + /** + * The entity for customers that may run multiple different entities, domains, + * sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, + * `google.com`, `youtube.com`, etc. + * If this is set, it should be exactly matched with + * UserEvent.entity google.cloud.retail.v2.UserEvent.entity to get + * per-entity autocomplete results. + */ + // const entity = 'abc123' + + // 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/google-cloud-retail/v2/samples/generated/v2/completion_service.import_completion_data.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/completion_service.import_completion_data.js new file mode 100644 index 00000000000..78b7b777c51 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/completion_service.import_completion_data.js @@ -0,0 +1,76 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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 is sent to + * specified Pub/Sub topic. The message data is 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/google-cloud-retail/v2/samples/generated/v2/control_service.create_control.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/control_service.create_control.js new file mode 100644 index 00000000000..74c6942875e --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/control_service.create_control.js @@ -0,0 +1,75 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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_v2_generated_ControlService_CreateControl_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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').v2; + + // 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_v2_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/google-cloud-retail/v2/samples/generated/v2/control_service.delete_control.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/control_service.delete_control.js new file mode 100644 index 00000000000..ab8f41c0d9c --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/control_service.delete_control.js @@ -0,0 +1,62 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by 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_ControlService_DeleteControl_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the 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').v2; + + // 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_v2_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/google-cloud-retail/v2/samples/generated/v2/control_service.get_control.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/control_service.get_control.js new file mode 100644 index 00000000000..dee1cbdef8f --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/control_service.get_control.js @@ -0,0 +1,62 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by 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_ControlService_GetControl_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the Control to get. 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').v2; + + // 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_v2_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/google-cloud-retail/v2/samples/generated/v2/control_service.list_controls.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/control_service.list_controls.js new file mode 100644 index 00000000000..d24b21f0fe7 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/control_service.list_controls.js @@ -0,0 +1,82 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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_ControlService_ListControls_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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.v2.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').v2; + + // 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_v2_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/google-cloud-retail/v2/samples/generated/v2/control_service.update_control.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/control_service.update_control.js new file mode 100644 index 00000000000..ea3160f0db8 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/control_service.update_control.js @@ -0,0 +1,69 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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_v2_generated_ControlService_UpdateControl_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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.v2.Control to update. The following are NOT + * supported: + * * Control.name google.cloud.retail.v2.Control.name + * If not set or empty, all supported fields are updated. + */ + // const updateMask = {} + + // Imports the Retail library + const {ControlServiceClient} = require('@google-cloud/retail').v2; + + // 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_v2_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/google-cloud-retail/v2/samples/generated/v2/model_service.create_model.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.create_model.js new file mode 100644 index 00000000000..f4a6164f20c --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.create_model.js @@ -0,0 +1,74 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, model) { + // [START retail_v2_generated_ModelService_CreateModel_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent resource under which to create the model. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + */ + // const parent = 'abc123' + /** + * Required. The payload of the Model google.cloud.retail.v2.Model to + * create. + */ + // const model = {} + /** + * Optional. Whether to run a dry run to validate the request (without + * actually creating the model). + */ + // const dryRun = true + + // Imports the Retail library + const {ModelServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ModelServiceClient(); + + async function callCreateModel() { + // Construct request + const request = { + parent, + model, + }; + + // Run request + const [operation] = await retailClient.createModel(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateModel(); + // [END retail_v2_generated_ModelService_CreateModel_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.delete_model.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.delete_model.js new file mode 100644 index 00000000000..41fd30a399e --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.delete_model.js @@ -0,0 +1,63 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by 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_ModelService_DeleteModel_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the Model google.cloud.retail.v2.Model to + * delete. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + */ + // const name = 'abc123' + + // Imports the Retail library + const {ModelServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ModelServiceClient(); + + async function callDeleteModel() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.deleteModel(request); + console.log(response); + } + + callDeleteModel(); + // [END retail_v2_generated_ModelService_DeleteModel_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.get_model.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.get_model.js new file mode 100644 index 00000000000..2624cd11c78 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.get_model.js @@ -0,0 +1,63 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by 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_ModelService_GetModel_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the Model google.cloud.retail.v2.Model to + * get. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog}/models/{model_id}` + */ + // const name = 'abc123' + + // Imports the Retail library + const {ModelServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ModelServiceClient(); + + async function callGetModel() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.getModel(request); + console.log(response); + } + + callGetModel(); + // [END retail_v2_generated_ModelService_GetModel_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.list_models.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.list_models.js new file mode 100644 index 00000000000..d0e2713e065 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.list_models.js @@ -0,0 +1,75 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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_ModelService_ListModels_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent for which to list models. + * 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 `ListModels` + * call. Provide this to retrieve the subsequent page. + */ + // const pageToken = 'abc123' + + // Imports the Retail library + const {ModelServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ModelServiceClient(); + + async function callListModels() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await retailClient.listModelsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListModels(); + // [END retail_v2_generated_ModelService_ListModels_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.pause_model.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.pause_model.js new file mode 100644 index 00000000000..13a1308d15d --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.pause_model.js @@ -0,0 +1,63 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by 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_ModelService_PauseModel_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the model to pause. + * Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + */ + // const name = 'abc123' + + // Imports the Retail library + const {ModelServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ModelServiceClient(); + + async function callPauseModel() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.pauseModel(request); + console.log(response); + } + + callPauseModel(); + // [END retail_v2_generated_ModelService_PauseModel_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.resume_model.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.resume_model.js new file mode 100644 index 00000000000..2fea1a0cead --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.resume_model.js @@ -0,0 +1,63 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by 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_ModelService_ResumeModel_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the model to resume. + * Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + */ + // const name = 'abc123' + + // Imports the Retail library + const {ModelServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ModelServiceClient(); + + async function callResumeModel() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.resumeModel(request); + console.log(response); + } + + callResumeModel(); + // [END retail_v2_generated_ModelService_ResumeModel_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.tune_model.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.tune_model.js new file mode 100644 index 00000000000..cc82aa7db90 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.tune_model.js @@ -0,0 +1,64 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by 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_ModelService_TuneModel_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the model to tune. + * Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + */ + // const name = 'abc123' + + // Imports the Retail library + const {ModelServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ModelServiceClient(); + + async function callTuneModel() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await retailClient.tuneModel(request); + const [response] = await operation.promise(); + console.log(response); + } + + callTuneModel(); + // [END retail_v2_generated_ModelService_TuneModel_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.update_model.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.update_model.js new file mode 100644 index 00000000000..2d7a2cbdb8c --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.update_model.js @@ -0,0 +1,66 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(model) { + // [START retail_v2_generated_ModelService_UpdateModel_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The body of the updated Model google.cloud.retail.v2.Model. + */ + // const model = {} + /** + * Optional. Indicates which fields in the provided 'model' to + * update. If not set, by default updates all fields. + */ + // const updateMask = {} + + // Imports the Retail library + const {ModelServiceClient} = require('@google-cloud/retail').v2; + + // Instantiates a client + const retailClient = new ModelServiceClient(); + + async function callUpdateModel() { + // Construct request + const request = { + model, + }; + + // Run request + const response = await retailClient.updateModel(request); + console.log(response); + } + + callUpdateModel(); + // [END retail_v2_generated_ModelService_UpdateModel_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/prediction_service.predict.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/prediction_service.predict.js new file mode 100644 index 00000000000..fffde01dc50 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/prediction_service.predict.js @@ -0,0 +1,187 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of the format: + * `{placement=projects/* /locations/global/catalogs/default_catalog/servingConfigs/*}` + * or + * `{placement=projects/* /locations/global/catalogs/default_catalog/placements/*}`. + * We recommend using the `servingConfigs` resource. `placements` is a legacy + * resource. + * The ID of the Recommendations AI serving config or placement. + * Before you can request predictions from your model, you must create at + * least one serving config or placement for it. For more information, see + * Manage serving configs + * (https://cloud.google.com/retail/docs/manage-configs). + * The full list of available serving configs can be seen at + * https://console.cloud.google.com/ai/retail/catalogs/default_catalog/configs + */ + // 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. 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 + /** + * This field is not used; leave it unset. + */ + // 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 *no* + * results. If instead you want empty result sets to return generic + * (unfiltered) popular products, set `strictFiltering` to False in + * `PredictRequest.params`. Note that the API will never return items with + * storageStatus of "EXPIRED" or "DELETED" regardless of filter choices. + * If `filterSyntaxV2` is set to true under the `params` field, then + * attribute-based expressions are expected instead of the above described + * tag-based syntax. Examples: + * * (colors: ANY("Red", "Blue")) AND NOT (categories: ANY("Phones")) + * * (availability: ANY("IN_STOCK")) AND + * (colors: ANY("Red") OR categories: ANY("Phones")) + * For more information, see + * Filter recommendations (https://cloud.google.com/retail/docs/filter-recs). + */ + // 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 a 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. + * * `filterSyntaxV2`: Boolean. False by default. If set to true, the `filter` + * field is interpreteted according to the new, attribute-based syntax. + */ + // 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/google-cloud-retail/v2/samples/generated/v2/product_service.add_fulfillment_places.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.add_fulfillment_places.js new file mode 100644 index 00000000000..ecd9092bd27 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.add_fulfillment_places.js @@ -0,0 +1,119 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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.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/google-cloud-retail/v2/samples/generated/v2/product_service.add_local_inventories.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.add_local_inventories.js new file mode 100644 index 00000000000..09806bed4c6 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.add_local_inventories.js @@ -0,0 +1,102 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2/samples/generated/v2/product_service.create_product.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.create_product.js new file mode 100644 index 00000000000..eb80e729016 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.create_product.js @@ -0,0 +1,83 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent 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/google-cloud-retail/v2/samples/generated/v2/product_service.delete_product.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.delete_product.js new file mode 100644 index 00000000000..3f7f79b1469 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.delete_product.js @@ -0,0 +1,77 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2/samples/generated/v2/product_service.get_product.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.get_product.js new file mode 100644 index 00000000000..e70274c74cb --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.get_product.js @@ -0,0 +1,68 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2/samples/generated/v2/product_service.import_products.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.import_products.js new file mode 100644 index 00000000000..cfbac96515d --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.import_products.js @@ -0,0 +1,98 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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, all fields are updated. + */ + // 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 is sent to + * specified Pub/Sub topic. The message data is 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 `service-@gcp-sa-retail.iam.gserviceaccount.com` has the + * `pubsub.topics.publish` IAM permission on the topic. + */ + // 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/google-cloud-retail/v2/samples/generated/v2/product_service.list_products.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.list_products.js new file mode 100644 index 00000000000..93dffde7845 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.list_products.js @@ -0,0 +1,133 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent 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/google-cloud-retail/v2/samples/generated/v2/product_service.remove_fulfillment_places.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.remove_fulfillment_places.js new file mode 100644 index 00000000000..036f23df698 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.remove_fulfillment_places.js @@ -0,0 +1,115 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2/samples/generated/v2/product_service.remove_local_inventories.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.remove_local_inventories.js new file mode 100644 index 00000000000..d553efef606 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.remove_local_inventories.js @@ -0,0 +1,88 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2/samples/generated/v2/product_service.set_inventory.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.set_inventory.js new file mode 100644 index 00000000000..94d00a7ee35 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.set_inventory.js @@ -0,0 +1,131 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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 google.cloud.retail.v2.Product.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 google.cloud.retail.v2.Product.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 google.cloud.retail.v2.Product.fulfillment_info + * * Checks that only the desired fulfillment info types have empty + * SetInventoryRequest.inventory.fulfillment_info.place_ids google.cloud.retail.v2.FulfillmentInfo.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, + * ProductService.UpdateProduct google.cloud.retail.v2.ProductService.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/google-cloud-retail/v2/samples/generated/v2/product_service.update_product.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.update_product.js new file mode 100644 index 00000000000..4295a19c341 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.update_product.js @@ -0,0 +1,87 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The product 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/google-cloud-retail/v2/samples/generated/v2/search_service.search.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/search_service.search.js new file mode 100644 index 00000000000..be3c113ec07 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/search_service.search.js @@ -0,0 +1,312 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the Retail Search serving config, such as + * `projects/* /locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` + * or the name of the legacy placement resource, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. + * This field is used to identify the serving config 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 200 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.v2.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, 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. + * Notice that if both + * ServingConfig.personalization_spec google.cloud.retail.v2.ServingConfig.personalization_spec + * and + * SearchRequest.personalization_spec google.cloud.retail.v2.SearchRequest.personalization_spec + * are set. + * SearchRequest.personalization_spec google.cloud.retail.v2.SearchRequest.personalization_spec + * will override + * ServingConfig.personalization_spec google.cloud.retail.v2.ServingConfig.personalization_spec. + */ + // 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 = {} + /** + * The entity for customers that may run multiple different entities, domains, + * sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, + * `google.com`, `youtube.com`, etc. + * If this is set, it should be exactly matched with + * UserEvent.entity google.cloud.retail.v2.UserEvent.entity to get search + * results boosted by entity. + */ + // const entity = 'abc123' + + // 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/google-cloud-retail/v2/samples/generated/v2/serving_config_service.add_control.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/serving_config_service.add_control.js new file mode 100644 index 00000000000..b6e99caa7c5 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/serving_config_service.add_control.js @@ -0,0 +1,68 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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_v2_generated_ServingConfigService_AddControl_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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').v2; + + // 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_v2_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/google-cloud-retail/v2/samples/generated/v2/serving_config_service.create_serving_config.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/serving_config_service.create_serving_config.js new file mode 100644 index 00000000000..9fbf0d7e5b2 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/serving_config_service.create_serving_config.js @@ -0,0 +1,75 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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_v2_generated_ServingConfigService_CreateServingConfig_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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').v2; + + // 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_v2_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/google-cloud-retail/v2/samples/generated/v2/serving_config_service.delete_serving_config.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/serving_config_service.delete_serving_config.js new file mode 100644 index 00000000000..7b947982621 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/serving_config_service.delete_serving_config.js @@ -0,0 +1,62 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by 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_ServingConfigService_DeleteServingConfig_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the 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').v2; + + // 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_v2_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/google-cloud-retail/v2/samples/generated/v2/serving_config_service.get_serving_config.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/serving_config_service.get_serving_config.js new file mode 100644 index 00000000000..40c17c87fce --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/serving_config_service.get_serving_config.js @@ -0,0 +1,62 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by 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_ServingConfigService_GetServingConfig_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the 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').v2; + + // 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_v2_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/google-cloud-retail/v2/samples/generated/v2/serving_config_service.list_serving_configs.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/serving_config_service.list_serving_configs.js new file mode 100644 index 00000000000..3393e11fe48 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/serving_config_service.list_serving_configs.js @@ -0,0 +1,75 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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_ServingConfigService_ListServingConfigs_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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').v2; + + // 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_v2_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/google-cloud-retail/v2/samples/generated/v2/serving_config_service.remove_control.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/serving_config_service.remove_control.js new file mode 100644 index 00000000000..bbcdb6f1caf --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/serving_config_service.remove_control.js @@ -0,0 +1,68 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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_v2_generated_ServingConfigService_RemoveControl_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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').v2; + + // 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_v2_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/google-cloud-retail/v2/samples/generated/v2/serving_config_service.update_serving_config.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/serving_config_service.update_serving_config.js new file mode 100644 index 00000000000..b4d671d1b98 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/serving_config_service.update_serving_config.js @@ -0,0 +1,69 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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_v2_generated_ServingConfigService_UpdateServingConfig_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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.v2.ServingConfig to update. The + * following are NOT supported: + * * ServingConfig.name google.cloud.retail.v2.ServingConfig.name + * If not set, all supported fields are updated. + */ + // const updateMask = {} + + // Imports the Retail library + const {ServingConfigServiceClient} = require('@google-cloud/retail').v2; + + // 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_v2_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/google-cloud-retail/v2/samples/generated/v2/snippet_metadata.google.cloud.retail.v2.json b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/snippet_metadata.google.cloud.retail.v2.json new file mode 100644 index 00000000000..8a1372432b3 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/snippet_metadata.google.cloud.retail.v2.json @@ -0,0 +1,2499 @@ +{ + "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": 78, + "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": 65, + "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": 76, + "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": 53, + "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_CatalogService_GetCompletionConfig_async", + "title": "CatalogService getCompletionConfig Sample", + "origin": "API_DEFINITION", + "description": " Gets a [CompletionConfig][google.cloud.retail.v2.CompletionConfig].", + "canonical": true, + "file": "catalog_service.get_completion_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetCompletionConfig", + "fullName": "google.cloud.retail.v2.CatalogService.GetCompletionConfig", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2.CompletionConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2.CatalogServiceClient" + }, + "method": { + "shortName": "GetCompletionConfig", + "fullName": "google.cloud.retail.v2.CatalogService.GetCompletionConfig", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_CatalogService_UpdateCompletionConfig_async", + "title": "CatalogService updateCompletionConfig Sample", + "origin": "API_DEFINITION", + "description": " Updates the [CompletionConfig][google.cloud.retail.v2.CompletionConfig]s.", + "canonical": true, + "file": "catalog_service.update_completion_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 70, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateCompletionConfig", + "fullName": "google.cloud.retail.v2.CatalogService.UpdateCompletionConfig", + "async": true, + "parameters": [ + { + "name": "completion_config", + "type": ".google.cloud.retail.v2.CompletionConfig" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2.CompletionConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2.CatalogServiceClient" + }, + "method": { + "shortName": "UpdateCompletionConfig", + "fullName": "google.cloud.retail.v2.CatalogService.UpdateCompletionConfig", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_CatalogService_GetAttributesConfig_async", + "title": "CatalogService getAttributesConfig Sample", + "origin": "API_DEFINITION", + "description": " Gets an [AttributesConfig][google.cloud.retail.v2.AttributesConfig].", + "canonical": true, + "file": "catalog_service.get_attributes_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetAttributesConfig", + "fullName": "google.cloud.retail.v2.CatalogService.GetAttributesConfig", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2.AttributesConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2.CatalogServiceClient" + }, + "method": { + "shortName": "GetAttributesConfig", + "fullName": "google.cloud.retail.v2.CatalogService.GetAttributesConfig", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_CatalogService_UpdateAttributesConfig_async", + "title": "CatalogService updateAttributesConfig Sample", + "origin": "API_DEFINITION", + "description": " Updates the [AttributesConfig][google.cloud.retail.v2.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": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateAttributesConfig", + "fullName": "google.cloud.retail.v2.CatalogService.UpdateAttributesConfig", + "async": true, + "parameters": [ + { + "name": "attributes_config", + "type": ".google.cloud.retail.v2.AttributesConfig" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2.AttributesConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2.CatalogServiceClient" + }, + "method": { + "shortName": "UpdateAttributesConfig", + "fullName": "google.cloud.retail.v2.CatalogService.UpdateAttributesConfig", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_CatalogService_AddCatalogAttribute_async", + "title": "CatalogService addCatalogAttribute Sample", + "origin": "API_DEFINITION", + "description": " Adds the specified [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] to the [AttributesConfig][google.cloud.retail.v2.AttributesConfig]. If the [CatalogAttribute][google.cloud.retail.v2.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": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddCatalogAttribute", + "fullName": "google.cloud.retail.v2.CatalogService.AddCatalogAttribute", + "async": true, + "parameters": [ + { + "name": "attributes_config", + "type": "TYPE_STRING" + }, + { + "name": "catalog_attribute", + "type": ".google.cloud.retail.v2.CatalogAttribute" + } + ], + "resultType": ".google.cloud.retail.v2.AttributesConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2.CatalogServiceClient" + }, + "method": { + "shortName": "AddCatalogAttribute", + "fullName": "google.cloud.retail.v2.CatalogService.AddCatalogAttribute", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_CatalogService_RemoveCatalogAttribute_async", + "title": "CatalogService removeCatalogAttribute Sample", + "origin": "API_DEFINITION", + "description": " Removes the specified [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] from the [AttributesConfig][google.cloud.retail.v2.AttributesConfig]. If the [CatalogAttribute][google.cloud.retail.v2.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": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveCatalogAttribute", + "fullName": "google.cloud.retail.v2.CatalogService.RemoveCatalogAttribute", + "async": true, + "parameters": [ + { + "name": "attributes_config", + "type": "TYPE_STRING" + }, + { + "name": "key", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2.AttributesConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2.CatalogServiceClient" + }, + "method": { + "shortName": "RemoveCatalogAttribute", + "fullName": "google.cloud.retail.v2.CatalogService.RemoveCatalogAttribute", + "service": { + "shortName": "CatalogService", + "fullName": "google.cloud.retail.v2.CatalogService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_CatalogService_ReplaceCatalogAttribute_async", + "title": "CatalogService replaceCatalogAttribute Sample", + "origin": "API_DEFINITION", + "description": " Replaces the specified [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] in the [AttributesConfig][google.cloud.retail.v2.AttributesConfig] by updating the catalog attribute with the same [CatalogAttribute.key][google.cloud.retail.v2.CatalogAttribute.key]. If the [CatalogAttribute][google.cloud.retail.v2.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": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ReplaceCatalogAttribute", + "fullName": "google.cloud.retail.v2.CatalogService.ReplaceCatalogAttribute", + "async": true, + "parameters": [ + { + "name": "attributes_config", + "type": "TYPE_STRING" + }, + { + "name": "catalog_attribute", + "type": ".google.cloud.retail.v2.CatalogAttribute" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2.AttributesConfig", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2.CatalogServiceClient" + }, + "method": { + "shortName": "ReplaceCatalogAttribute", + "fullName": "google.cloud.retail.v2.CatalogService.ReplaceCatalogAttribute", + "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. Enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "completion_service.complete_query.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 124, + "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" + }, + { + "name": "entity", + "type": "TYPE_STRING" + } + ], + "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. 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": 68, + "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_ControlService_CreateControl_async", + "title": "CatalogService createControl Sample", + "origin": "API_DEFINITION", + "description": " Creates a Control. If the [Control][google.cloud.retail.v2.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": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateControl", + "fullName": "google.cloud.retail.v2.ControlService.CreateControl", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "control", + "type": ".google.cloud.retail.v2.Control" + }, + { + "name": "control_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2.Control", + "client": { + "shortName": "ControlServiceClient", + "fullName": "google.cloud.retail.v2.ControlServiceClient" + }, + "method": { + "shortName": "CreateControl", + "fullName": "google.cloud.retail.v2.ControlService.CreateControl", + "service": { + "shortName": "ControlService", + "fullName": "google.cloud.retail.v2.ControlService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ControlService_DeleteControl_async", + "title": "CatalogService deleteControl Sample", + "origin": "API_DEFINITION", + "description": " Deletes a Control. If the [Control][google.cloud.retail.v2.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": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteControl", + "fullName": "google.cloud.retail.v2.ControlService.DeleteControl", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ControlServiceClient", + "fullName": "google.cloud.retail.v2.ControlServiceClient" + }, + "method": { + "shortName": "DeleteControl", + "fullName": "google.cloud.retail.v2.ControlService.DeleteControl", + "service": { + "shortName": "ControlService", + "fullName": "google.cloud.retail.v2.ControlService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ControlService_UpdateControl_async", + "title": "CatalogService updateControl Sample", + "origin": "API_DEFINITION", + "description": " Updates a Control. [Control][google.cloud.retail.v2.Control] cannot be set to a different oneof field, if so an INVALID_ARGUMENT is returned. If the [Control][google.cloud.retail.v2.Control] to update does not exist, a NOT_FOUND error is returned.", + "canonical": true, + "file": "control_service.update_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 61, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateControl", + "fullName": "google.cloud.retail.v2.ControlService.UpdateControl", + "async": true, + "parameters": [ + { + "name": "control", + "type": ".google.cloud.retail.v2.Control" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2.Control", + "client": { + "shortName": "ControlServiceClient", + "fullName": "google.cloud.retail.v2.ControlServiceClient" + }, + "method": { + "shortName": "UpdateControl", + "fullName": "google.cloud.retail.v2.ControlService.UpdateControl", + "service": { + "shortName": "ControlService", + "fullName": "google.cloud.retail.v2.ControlService" + } + } + } + }, + { + "regionTag": "retail_v2_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": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetControl", + "fullName": "google.cloud.retail.v2.ControlService.GetControl", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2.Control", + "client": { + "shortName": "ControlServiceClient", + "fullName": "google.cloud.retail.v2.ControlServiceClient" + }, + "method": { + "shortName": "GetControl", + "fullName": "google.cloud.retail.v2.ControlService.GetControl", + "service": { + "shortName": "ControlService", + "fullName": "google.cloud.retail.v2.ControlService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ControlService_ListControls_async", + "title": "CatalogService listControls Sample", + "origin": "API_DEFINITION", + "description": " Lists all Controls by their parent [Catalog][google.cloud.retail.v2.Catalog].", + "canonical": true, + "file": "control_service.list_controls.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 74, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListControls", + "fullName": "google.cloud.retail.v2.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.v2.ListControlsResponse", + "client": { + "shortName": "ControlServiceClient", + "fullName": "google.cloud.retail.v2.ControlServiceClient" + }, + "method": { + "shortName": "ListControls", + "fullName": "google.cloud.retail.v2.ControlService.ListControls", + "service": { + "shortName": "ControlService", + "fullName": "google.cloud.retail.v2.ControlService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ModelService_CreateModel_async", + "title": "CatalogService createModel Sample", + "origin": "API_DEFINITION", + "description": " Creates a new model.", + "canonical": true, + "file": "model_service.create_model.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateModel", + "fullName": "google.cloud.retail.v2.ModelService.CreateModel", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "model", + "type": ".google.cloud.retail.v2.Model" + }, + { + "name": "dry_run", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ModelServiceClient", + "fullName": "google.cloud.retail.v2.ModelServiceClient" + }, + "method": { + "shortName": "CreateModel", + "fullName": "google.cloud.retail.v2.ModelService.CreateModel", + "service": { + "shortName": "ModelService", + "fullName": "google.cloud.retail.v2.ModelService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ModelService_GetModel_async", + "title": "CatalogService getModel Sample", + "origin": "API_DEFINITION", + "description": " Gets a model.", + "canonical": true, + "file": "model_service.get_model.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetModel", + "fullName": "google.cloud.retail.v2.ModelService.GetModel", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2.Model", + "client": { + "shortName": "ModelServiceClient", + "fullName": "google.cloud.retail.v2.ModelServiceClient" + }, + "method": { + "shortName": "GetModel", + "fullName": "google.cloud.retail.v2.ModelService.GetModel", + "service": { + "shortName": "ModelService", + "fullName": "google.cloud.retail.v2.ModelService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ModelService_PauseModel_async", + "title": "CatalogService pauseModel Sample", + "origin": "API_DEFINITION", + "description": " Pauses the training of an existing model.", + "canonical": true, + "file": "model_service.pause_model.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PauseModel", + "fullName": "google.cloud.retail.v2.ModelService.PauseModel", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2.Model", + "client": { + "shortName": "ModelServiceClient", + "fullName": "google.cloud.retail.v2.ModelServiceClient" + }, + "method": { + "shortName": "PauseModel", + "fullName": "google.cloud.retail.v2.ModelService.PauseModel", + "service": { + "shortName": "ModelService", + "fullName": "google.cloud.retail.v2.ModelService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ModelService_ResumeModel_async", + "title": "CatalogService resumeModel Sample", + "origin": "API_DEFINITION", + "description": " Resumes the training of an existing model.", + "canonical": true, + "file": "model_service.resume_model.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ResumeModel", + "fullName": "google.cloud.retail.v2.ModelService.ResumeModel", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2.Model", + "client": { + "shortName": "ModelServiceClient", + "fullName": "google.cloud.retail.v2.ModelServiceClient" + }, + "method": { + "shortName": "ResumeModel", + "fullName": "google.cloud.retail.v2.ModelService.ResumeModel", + "service": { + "shortName": "ModelService", + "fullName": "google.cloud.retail.v2.ModelService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ModelService_DeleteModel_async", + "title": "CatalogService deleteModel Sample", + "origin": "API_DEFINITION", + "description": " Deletes an existing model.", + "canonical": true, + "file": "model_service.delete_model.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteModel", + "fullName": "google.cloud.retail.v2.ModelService.DeleteModel", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ModelServiceClient", + "fullName": "google.cloud.retail.v2.ModelServiceClient" + }, + "method": { + "shortName": "DeleteModel", + "fullName": "google.cloud.retail.v2.ModelService.DeleteModel", + "service": { + "shortName": "ModelService", + "fullName": "google.cloud.retail.v2.ModelService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ModelService_ListModels_async", + "title": "CatalogService listModels Sample", + "origin": "API_DEFINITION", + "description": " Lists all the models linked to this event store.", + "canonical": true, + "file": "model_service.list_models.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListModels", + "fullName": "google.cloud.retail.v2.ModelService.ListModels", + "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.ListModelsResponse", + "client": { + "shortName": "ModelServiceClient", + "fullName": "google.cloud.retail.v2.ModelServiceClient" + }, + "method": { + "shortName": "ListModels", + "fullName": "google.cloud.retail.v2.ModelService.ListModels", + "service": { + "shortName": "ModelService", + "fullName": "google.cloud.retail.v2.ModelService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ModelService_UpdateModel_async", + "title": "CatalogService updateModel Sample", + "origin": "API_DEFINITION", + "description": " Update of model metadata. Only fields that currently can be updated are: `filtering_option` and `periodic_tuning_state`. If other values are provided, this API method ignores them.", + "canonical": true, + "file": "model_service.update_model.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateModel", + "fullName": "google.cloud.retail.v2.ModelService.UpdateModel", + "async": true, + "parameters": [ + { + "name": "model", + "type": ".google.cloud.retail.v2.Model" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2.Model", + "client": { + "shortName": "ModelServiceClient", + "fullName": "google.cloud.retail.v2.ModelServiceClient" + }, + "method": { + "shortName": "UpdateModel", + "fullName": "google.cloud.retail.v2.ModelService.UpdateModel", + "service": { + "shortName": "ModelService", + "fullName": "google.cloud.retail.v2.ModelService" + } + } + } + }, + { + "regionTag": "retail_v2_generated_ModelService_TuneModel_async", + "title": "CatalogService tuneModel Sample", + "origin": "API_DEFINITION", + "description": " Tunes an existing model.", + "canonical": true, + "file": "model_service.tune_model.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 56, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TuneModel", + "fullName": "google.cloud.retail.v2.ModelService.TuneModel", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ModelServiceClient", + "fullName": "google.cloud.retail.v2.ModelServiceClient" + }, + "method": { + "shortName": "TuneModel", + "fullName": "google.cloud.retail.v2.ModelService.TuneModel", + "service": { + "shortName": "ModelService", + "fullName": "google.cloud.retail.v2.ModelService" + } + } + } + }, + { + "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": 179, + "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": 75, + "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": 60, + "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": 125, + "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": 79, + "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": 69, + "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": 90, + "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 is 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 [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. When inventory is updated with [ProductService.CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] and [ProductService.UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct], the specified inventory field value(s) overwrite any existing value(s) while ignoring the last update time for this field. Furthermore, the last update times for the specified inventory fields are overwritten by the times of the [ProductService.CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] or [ProductService.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 is used. If no inventory fields are set in [SetInventoryRequest.set_mask][google.cloud.retail.v2.SetInventoryRequest.set_mask], then any existing inventory information is preserved. Pre-existing inventory information can only be updated with [ProductService.SetInventory][google.cloud.retail.v2.ProductService.SetInventory], [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2.ProductService.AddFulfillmentPlaces], and [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces]. The returned [Operation][google.longrunning.Operation]s is obsolete after one day, and the [GetOperation][google.longrunning.Operations.GetOperation] API returns `NOT_FOUND` afterwards. If conflicting updates are issued, the [Operation][google.longrunning.Operation]s associated with the stale updates are not marked as [done][google.longrunning.Operation.done] until they are obsolete.", + "canonical": true, + "file": "product_service.set_inventory.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 123, + "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": " It is recommended to use the [ProductService.AddLocalInventories][google.cloud.retail.v2.ProductService.AddLocalInventories] method instead of [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2.ProductService.AddFulfillmentPlaces]. [ProductService.AddLocalInventories][google.cloud.retail.v2.ProductService.AddLocalInventories] achieves the same results but provides more fine-grained control over ingesting local inventory data. 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 [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. The returned [Operation][google.longrunning.Operation]s will be obsolete after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] API will return NOT_FOUND afterwards. If conflicting updates are issued, the [Operation][google.longrunning.Operation]s associated with the stale updates will not be marked as [done][google.longrunning.Operation.done] until being obsolete.", + "canonical": true, + "file": "product_service.add_fulfillment_places.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 111, + "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": " It is recommended to use the [ProductService.RemoveLocalInventories][google.cloud.retail.v2.ProductService.RemoveLocalInventories] method instead of [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces]. [ProductService.RemoveLocalInventories][google.cloud.retail.v2.ProductService.RemoveLocalInventories] achieves the same results but provides more fine-grained control over ingesting local inventory data. 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 [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. The returned [Operation][google.longrunning.Operation]s will be obsolete after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] API will return NOT_FOUND afterwards. If conflicting updates are issued, the [Operation][google.longrunning.Operation]s associated with the stale updates will not be marked as [done][google.longrunning.Operation.done] until being obsolete.", + "canonical": true, + "file": "product_service.remove_fulfillment_places.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 107, + "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 [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. Local inventory information can only be modified using this method. [ProductService.CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] and [ProductService.UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] has no effect on local inventories. The returned [Operation][google.longrunning.Operation]s will be obsolete after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] API will return NOT_FOUND afterwards. If conflicting updates are issued, the [Operation][google.longrunning.Operation]s associated with the stale updates will not be marked as [done][google.longrunning.Operation.done] until being obsolete.", + "canonical": true, + "file": "product_service.add_local_inventories.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 94, + "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 [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. Local inventory information can only be removed using this method. [ProductService.CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] and [ProductService.UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] has no effect on local inventories. The returned [Operation][google.longrunning.Operation]s will be obsolete after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] API will return NOT_FOUND afterwards. If conflicting updates are issued, the [Operation][google.longrunning.Operation]s associated with the stale updates will not be marked as [done][google.longrunning.Operation.done] until being obsolete.", + "canonical": true, + "file": "product_service.remove_local_inventories.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "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. Enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "search_service.search.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 304, + "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" + }, + { + "name": "entity", + "type": "TYPE_STRING" + } + ], + "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_ServingConfigService_CreateServingConfig_async", + "title": "CatalogService createServingConfig Sample", + "origin": "API_DEFINITION", + "description": " Creates a ServingConfig. A maximum of 100 [ServingConfig][google.cloud.retail.v2.ServingConfig]s are allowed in a [Catalog][google.cloud.retail.v2.Catalog], otherwise a FAILED_PRECONDITION error is returned.", + "canonical": true, + "file": "serving_config_service.create_serving_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateServingConfig", + "fullName": "google.cloud.retail.v2.ServingConfigService.CreateServingConfig", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "serving_config", + "type": ".google.cloud.retail.v2.ServingConfig" + }, + { + "name": "serving_config_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2.ServingConfig", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2.ServingConfigServiceClient" + }, + "method": { + "shortName": "CreateServingConfig", + "fullName": "google.cloud.retail.v2.ServingConfigService.CreateServingConfig", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2_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": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteServingConfig", + "fullName": "google.cloud.retail.v2.ServingConfigService.DeleteServingConfig", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2.ServingConfigServiceClient" + }, + "method": { + "shortName": "DeleteServingConfig", + "fullName": "google.cloud.retail.v2.ServingConfigService.DeleteServingConfig", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2_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": 61, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateServingConfig", + "fullName": "google.cloud.retail.v2.ServingConfigService.UpdateServingConfig", + "async": true, + "parameters": [ + { + "name": "serving_config", + "type": ".google.cloud.retail.v2.ServingConfig" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2.ServingConfig", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2.ServingConfigServiceClient" + }, + "method": { + "shortName": "UpdateServingConfig", + "fullName": "google.cloud.retail.v2.ServingConfigService.UpdateServingConfig", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2_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": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetServingConfig", + "fullName": "google.cloud.retail.v2.ServingConfigService.GetServingConfig", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2.ServingConfig", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2.ServingConfigServiceClient" + }, + "method": { + "shortName": "GetServingConfig", + "fullName": "google.cloud.retail.v2.ServingConfigService.GetServingConfig", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2_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": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListServingConfigs", + "fullName": "google.cloud.retail.v2.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.v2.ListServingConfigsResponse", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2.ServingConfigServiceClient" + }, + "method": { + "shortName": "ListServingConfigs", + "fullName": "google.cloud.retail.v2.ServingConfigService.ListServingConfigs", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2_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": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AddControl", + "fullName": "google.cloud.retail.v2.ServingConfigService.AddControl", + "async": true, + "parameters": [ + { + "name": "serving_config", + "type": "TYPE_STRING" + }, + { + "name": "control_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2.ServingConfig", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2.ServingConfigServiceClient" + }, + "method": { + "shortName": "AddControl", + "fullName": "google.cloud.retail.v2.ServingConfigService.AddControl", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2.ServingConfigService" + } + } + } + }, + { + "regionTag": "retail_v2_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": 60, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RemoveControl", + "fullName": "google.cloud.retail.v2.ServingConfigService.RemoveControl", + "async": true, + "parameters": [ + { + "name": "serving_config", + "type": "TYPE_STRING" + }, + { + "name": "control_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2.ServingConfig", + "client": { + "shortName": "ServingConfigServiceClient", + "fullName": "google.cloud.retail.v2.ServingConfigServiceClient" + }, + "method": { + "shortName": "RemoveControl", + "fullName": "google.cloud.retail.v2.ServingConfigService.RemoveControl", + "service": { + "shortName": "ServingConfigService", + "fullName": "google.cloud.retail.v2.ServingConfigService" + } + } + } + }, + { + "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": 66, + "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" + }, + { + "name": "write_async", + "type": "TYPE_BOOL" + } + ], + "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": 85, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CollectUserEvent", + "fullName": "google.cloud.retail.v2.UserEventService.CollectUserEvent", + "async": true, + "parameters": [ + { + "name": "prebuilt_rule", + "type": "TYPE_STRING" + }, + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "user_event", + "type": "TYPE_STRING" + }, + { + "name": "uri", + "type": "TYPE_STRING" + }, + { + "name": "ets", + "type": "TYPE_INT64" + }, + { + "name": "raw_json", + "type": "TYPE_STRING" + } + ], + "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": 85, + "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": 64, + "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 are not annotated with detailed product information for products that are missing from the catalog when the user event is ingested. These events are stored as unjoined events with limited usage on training and serving. You can use this method to start a join operation on specified events with the latest version of product catalog. You can also use this method 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": 62, + "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/google-cloud-retail/v2/samples/generated/v2/user_event_service.collect_user_event.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/user_event_service.collect_user_event.js new file mode 100644 index 00000000000..9e37dc26a8d --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/user_event_service.collect_user_event.js @@ -0,0 +1,93 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * The prebuilt rule name that can convert a specific type of raw_json. + * For example: "ga4_bq" rule for the GA4 user event schema. + */ + // const prebuiltRule = 'abc123' + /** + * 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 + /** + * An arbitrary serialized JSON string that contains necessary information + * that can comprise a user event. When this field is specified, the + * user_event field will be ignored. Note: line-delimited JSON is not + * supported, a single JSON only. + */ + // const rawJson = 'abc123' + + // 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/google-cloud-retail/v2/samples/generated/v2/user_event_service.import_user_events.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/user_event_service.import_user_events.js new file mode 100644 index 00000000000..f7410fdd4f3 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/user_event_service.import_user_events.js @@ -0,0 +1,72 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2/samples/generated/v2/user_event_service.purge_user_events.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/user_event_service.purge_user_events.js new file mode 100644 index 00000000000..b96b3fdd6e8 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/user_event_service.purge_user_events.js @@ -0,0 +1,93 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the 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/google-cloud-retail/v2/samples/generated/v2/user_event_service.rejoin_user_events.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/user_event_service.rejoin_user_events.js new file mode 100644 index 00000000000..ac4e6ad1e23 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/user_event_service.rejoin_user_events.js @@ -0,0 +1,70 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent 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/google-cloud-retail/v2/samples/generated/v2/user_event_service.write_user_event.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/user_event_service.write_user_event.js new file mode 100644 index 00000000000..b71384d22e8 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/user_event_service.write_user_event.js @@ -0,0 +1,74 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent catalog resource name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + */ + // const parent = 'abc123' + /** + * Required. User event to write. + */ + // const userEvent = {} + /** + * If set to true, the user event will be written asynchronously after + * validation, and the API will respond without waiting for the write. + * Therefore, silent failures can occur even if the API returns success. In + * case of silent failures, error messages can be found in Stackdriver logs. + */ + // const writeAsync = true + + // 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/google-cloud-retail/v2/src/index.ts b/owl-bot-staging/google-cloud-retail/v2/src/index.ts new file mode 100644 index 00000000000..326bdd05f98 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/src/index.ts @@ -0,0 +1,41 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This 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 ControlServiceClient = v2.ControlServiceClient; +type ControlServiceClient = v2.ControlServiceClient; +const ModelServiceClient = v2.ModelServiceClient; +type ModelServiceClient = v2.ModelServiceClient; +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 ServingConfigServiceClient = v2.ServingConfigServiceClient; +type ServingConfigServiceClient = v2.ServingConfigServiceClient; +const UserEventServiceClient = v2.UserEventServiceClient; +type UserEventServiceClient = v2.UserEventServiceClient; +export {v2, CatalogServiceClient, CompletionServiceClient, ControlServiceClient, ModelServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, ServingConfigServiceClient, UserEventServiceClient}; +export default {v2, CatalogServiceClient, CompletionServiceClient, ControlServiceClient, ModelServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, ServingConfigServiceClient, UserEventServiceClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-retail/v2/src/v2/catalog_service_client.ts b/owl-bot-staging/google-cloud-retail/v2/src/v2/catalog_service_client.ts new file mode 100644 index 00000000000..1d0d40dc106 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/src/v2/catalog_service_client.ts @@ -0,0 +1,2223 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/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}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + 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/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new CatalogServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof 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); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + 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}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + 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') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2/{name=projects/*/locations/*/operations/*}',additional_bindings: [{get: '/v2/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',},{get: '/v2/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2/{name=projects/*/operations/*}',}], + },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2/{name=projects/*/locations/*}/operations',additional_bindings: [{get: '/v2/{name=projects/*/locations/*/catalogs/*}/operations',},{get: '/v2/{name=projects/*}/operations',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + + this.descriptors.longrunning = { + }; + + // 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 = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.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', '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._opts.fallback + ); + + 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 {@link google.cloud.retail.v2.Catalog | 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' + ] = this._gaxModule.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 {@link google.protobuf.Empty | 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' + ] = this._gaxModule.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 {@link google.cloud.retail.v2.GetDefaultBranchResponse | 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'catalog': request.catalog ?? '', + }); + this.initialize(); + return this.innerApiCalls.getDefaultBranch(request, options, callback); + } +/** + * Gets a {@link google.cloud.retail.v2.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 {@link google.cloud.retail.v2.CompletionConfig | 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/v2/catalog_service.get_completion_config.js + * region_tag:retail_v2_generated_CatalogService_GetCompletionConfig_async + */ + getCompletionConfig( + request?: protos.google.cloud.retail.v2.IGetCompletionConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2.ICompletionConfig, + protos.google.cloud.retail.v2.IGetCompletionConfigRequest|undefined, {}|undefined + ]>; + getCompletionConfig( + request: protos.google.cloud.retail.v2.IGetCompletionConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.ICompletionConfig, + protos.google.cloud.retail.v2.IGetCompletionConfigRequest|null|undefined, + {}|null|undefined>): void; + getCompletionConfig( + request: protos.google.cloud.retail.v2.IGetCompletionConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2.ICompletionConfig, + protos.google.cloud.retail.v2.IGetCompletionConfigRequest|null|undefined, + {}|null|undefined>): void; + getCompletionConfig( + request?: protos.google.cloud.retail.v2.IGetCompletionConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2.ICompletionConfig, + protos.google.cloud.retail.v2.IGetCompletionConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2.ICompletionConfig, + protos.google.cloud.retail.v2.IGetCompletionConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2.ICompletionConfig, + protos.google.cloud.retail.v2.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' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getCompletionConfig(request, options, callback); + } +/** + * Updates the {@link google.cloud.retail.v2.CompletionConfig|CompletionConfig}s. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2.CompletionConfig} request.completionConfig + * Required. The {@link google.cloud.retail.v2.CompletionConfig|CompletionConfig} + * to update. + * + * If the caller does not have permission to update the + * {@link google.cloud.retail.v2.CompletionConfig|CompletionConfig}, then a + * PERMISSION_DENIED error is returned. + * + * If the {@link google.cloud.retail.v2.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.v2.CompletionConfig|CompletionConfig} to update. The + * following are the only supported fields: + * + * * {@link google.cloud.retail.v2.CompletionConfig.matching_order|CompletionConfig.matching_order} + * * {@link google.cloud.retail.v2.CompletionConfig.max_suggestions|CompletionConfig.max_suggestions} + * * {@link google.cloud.retail.v2.CompletionConfig.min_prefix_length|CompletionConfig.min_prefix_length} + * * {@link google.cloud.retail.v2.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 {@link google.cloud.retail.v2.CompletionConfig | 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/v2/catalog_service.update_completion_config.js + * region_tag:retail_v2_generated_CatalogService_UpdateCompletionConfig_async + */ + updateCompletionConfig( + request?: protos.google.cloud.retail.v2.IUpdateCompletionConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2.ICompletionConfig, + protos.google.cloud.retail.v2.IUpdateCompletionConfigRequest|undefined, {}|undefined + ]>; + updateCompletionConfig( + request: protos.google.cloud.retail.v2.IUpdateCompletionConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.ICompletionConfig, + protos.google.cloud.retail.v2.IUpdateCompletionConfigRequest|null|undefined, + {}|null|undefined>): void; + updateCompletionConfig( + request: protos.google.cloud.retail.v2.IUpdateCompletionConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2.ICompletionConfig, + protos.google.cloud.retail.v2.IUpdateCompletionConfigRequest|null|undefined, + {}|null|undefined>): void; + updateCompletionConfig( + request?: protos.google.cloud.retail.v2.IUpdateCompletionConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2.ICompletionConfig, + protos.google.cloud.retail.v2.IUpdateCompletionConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2.ICompletionConfig, + protos.google.cloud.retail.v2.IUpdateCompletionConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2.ICompletionConfig, + protos.google.cloud.retail.v2.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' + ] = this._gaxModule.routingHeader.fromParams({ + 'completion_config.name': request.completionConfig!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateCompletionConfig(request, options, callback); + } +/** + * Gets an {@link google.cloud.retail.v2.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 {@link google.cloud.retail.v2.AttributesConfig | 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/v2/catalog_service.get_attributes_config.js + * region_tag:retail_v2_generated_CatalogService_GetAttributesConfig_async + */ + getAttributesConfig( + request?: protos.google.cloud.retail.v2.IGetAttributesConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2.IAttributesConfig, + protos.google.cloud.retail.v2.IGetAttributesConfigRequest|undefined, {}|undefined + ]>; + getAttributesConfig( + request: protos.google.cloud.retail.v2.IGetAttributesConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IAttributesConfig, + protos.google.cloud.retail.v2.IGetAttributesConfigRequest|null|undefined, + {}|null|undefined>): void; + getAttributesConfig( + request: protos.google.cloud.retail.v2.IGetAttributesConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2.IAttributesConfig, + protos.google.cloud.retail.v2.IGetAttributesConfigRequest|null|undefined, + {}|null|undefined>): void; + getAttributesConfig( + request?: protos.google.cloud.retail.v2.IGetAttributesConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2.IAttributesConfig, + protos.google.cloud.retail.v2.IGetAttributesConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2.IAttributesConfig, + protos.google.cloud.retail.v2.IGetAttributesConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2.IAttributesConfig, + protos.google.cloud.retail.v2.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' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getAttributesConfig(request, options, callback); + } +/** + * Updates the {@link google.cloud.retail.v2.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.v2.AttributesConfig} request.attributesConfig + * Required. The {@link google.cloud.retail.v2.AttributesConfig|AttributesConfig} + * to update. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2.AttributesConfig|AttributesConfig} to update. The + * following is the only supported field: + * + * * {@link google.cloud.retail.v2.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 {@link google.cloud.retail.v2.AttributesConfig | 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/v2/catalog_service.update_attributes_config.js + * region_tag:retail_v2_generated_CatalogService_UpdateAttributesConfig_async + */ + updateAttributesConfig( + request?: protos.google.cloud.retail.v2.IUpdateAttributesConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2.IAttributesConfig, + protos.google.cloud.retail.v2.IUpdateAttributesConfigRequest|undefined, {}|undefined + ]>; + updateAttributesConfig( + request: protos.google.cloud.retail.v2.IUpdateAttributesConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IAttributesConfig, + protos.google.cloud.retail.v2.IUpdateAttributesConfigRequest|null|undefined, + {}|null|undefined>): void; + updateAttributesConfig( + request: protos.google.cloud.retail.v2.IUpdateAttributesConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2.IAttributesConfig, + protos.google.cloud.retail.v2.IUpdateAttributesConfigRequest|null|undefined, + {}|null|undefined>): void; + updateAttributesConfig( + request?: protos.google.cloud.retail.v2.IUpdateAttributesConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2.IAttributesConfig, + protos.google.cloud.retail.v2.IUpdateAttributesConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2.IAttributesConfig, + protos.google.cloud.retail.v2.IUpdateAttributesConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2.IAttributesConfig, + protos.google.cloud.retail.v2.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' + ] = this._gaxModule.routingHeader.fromParams({ + 'attributes_config.name': request.attributesConfig!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateAttributesConfig(request, options, callback); + } +/** + * Adds the specified + * {@link google.cloud.retail.v2.CatalogAttribute|CatalogAttribute} to the + * {@link google.cloud.retail.v2.AttributesConfig|AttributesConfig}. + * + * If the {@link google.cloud.retail.v2.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.v2.CatalogAttribute} request.catalogAttribute + * Required. The {@link google.cloud.retail.v2.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 {@link google.cloud.retail.v2.AttributesConfig | 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/v2/catalog_service.add_catalog_attribute.js + * region_tag:retail_v2_generated_CatalogService_AddCatalogAttribute_async + */ + addCatalogAttribute( + request?: protos.google.cloud.retail.v2.IAddCatalogAttributeRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2.IAttributesConfig, + protos.google.cloud.retail.v2.IAddCatalogAttributeRequest|undefined, {}|undefined + ]>; + addCatalogAttribute( + request: protos.google.cloud.retail.v2.IAddCatalogAttributeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IAttributesConfig, + protos.google.cloud.retail.v2.IAddCatalogAttributeRequest|null|undefined, + {}|null|undefined>): void; + addCatalogAttribute( + request: protos.google.cloud.retail.v2.IAddCatalogAttributeRequest, + callback: Callback< + protos.google.cloud.retail.v2.IAttributesConfig, + protos.google.cloud.retail.v2.IAddCatalogAttributeRequest|null|undefined, + {}|null|undefined>): void; + addCatalogAttribute( + request?: protos.google.cloud.retail.v2.IAddCatalogAttributeRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2.IAttributesConfig, + protos.google.cloud.retail.v2.IAddCatalogAttributeRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2.IAttributesConfig, + protos.google.cloud.retail.v2.IAddCatalogAttributeRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2.IAttributesConfig, + protos.google.cloud.retail.v2.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' + ] = this._gaxModule.routingHeader.fromParams({ + 'attributes_config': request.attributesConfig ?? '', + }); + this.initialize(); + return this.innerApiCalls.addCatalogAttribute(request, options, callback); + } +/** + * Removes the specified + * {@link google.cloud.retail.v2.CatalogAttribute|CatalogAttribute} from the + * {@link google.cloud.retail.v2.AttributesConfig|AttributesConfig}. + * + * If the {@link google.cloud.retail.v2.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.v2.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 {@link google.cloud.retail.v2.AttributesConfig | 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/v2/catalog_service.remove_catalog_attribute.js + * region_tag:retail_v2_generated_CatalogService_RemoveCatalogAttribute_async + */ + removeCatalogAttribute( + request?: protos.google.cloud.retail.v2.IRemoveCatalogAttributeRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2.IAttributesConfig, + protos.google.cloud.retail.v2.IRemoveCatalogAttributeRequest|undefined, {}|undefined + ]>; + removeCatalogAttribute( + request: protos.google.cloud.retail.v2.IRemoveCatalogAttributeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IAttributesConfig, + protos.google.cloud.retail.v2.IRemoveCatalogAttributeRequest|null|undefined, + {}|null|undefined>): void; + removeCatalogAttribute( + request: protos.google.cloud.retail.v2.IRemoveCatalogAttributeRequest, + callback: Callback< + protos.google.cloud.retail.v2.IAttributesConfig, + protos.google.cloud.retail.v2.IRemoveCatalogAttributeRequest|null|undefined, + {}|null|undefined>): void; + removeCatalogAttribute( + request?: protos.google.cloud.retail.v2.IRemoveCatalogAttributeRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2.IAttributesConfig, + protos.google.cloud.retail.v2.IRemoveCatalogAttributeRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2.IAttributesConfig, + protos.google.cloud.retail.v2.IRemoveCatalogAttributeRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2.IAttributesConfig, + protos.google.cloud.retail.v2.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' + ] = this._gaxModule.routingHeader.fromParams({ + 'attributes_config': request.attributesConfig ?? '', + }); + this.initialize(); + return this.innerApiCalls.removeCatalogAttribute(request, options, callback); + } +/** + * Replaces the specified + * {@link google.cloud.retail.v2.CatalogAttribute|CatalogAttribute} in the + * {@link google.cloud.retail.v2.AttributesConfig|AttributesConfig} by updating the + * catalog attribute with the same + * {@link google.cloud.retail.v2.CatalogAttribute.key|CatalogAttribute.key}. + * + * If the {@link google.cloud.retail.v2.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.v2.CatalogAttribute} request.catalogAttribute + * Required. The updated + * {@link google.cloud.retail.v2.CatalogAttribute|CatalogAttribute}. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2.CatalogAttribute|CatalogAttribute} to update. The + * following are NOT supported: + * + * * {@link google.cloud.retail.v2.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 {@link google.cloud.retail.v2.AttributesConfig | 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/v2/catalog_service.replace_catalog_attribute.js + * region_tag:retail_v2_generated_CatalogService_ReplaceCatalogAttribute_async + */ + replaceCatalogAttribute( + request?: protos.google.cloud.retail.v2.IReplaceCatalogAttributeRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2.IAttributesConfig, + protos.google.cloud.retail.v2.IReplaceCatalogAttributeRequest|undefined, {}|undefined + ]>; + replaceCatalogAttribute( + request: protos.google.cloud.retail.v2.IReplaceCatalogAttributeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IAttributesConfig, + protos.google.cloud.retail.v2.IReplaceCatalogAttributeRequest|null|undefined, + {}|null|undefined>): void; + replaceCatalogAttribute( + request: protos.google.cloud.retail.v2.IReplaceCatalogAttributeRequest, + callback: Callback< + protos.google.cloud.retail.v2.IAttributesConfig, + protos.google.cloud.retail.v2.IReplaceCatalogAttributeRequest|null|undefined, + {}|null|undefined>): void; + replaceCatalogAttribute( + request?: protos.google.cloud.retail.v2.IReplaceCatalogAttributeRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2.IAttributesConfig, + protos.google.cloud.retail.v2.IReplaceCatalogAttributeRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2.IAttributesConfig, + protos.google.cloud.retail.v2.IReplaceCatalogAttributeRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2.IAttributesConfig, + protos.google.cloud.retail.v2.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' + ] = this._gaxModule.routingHeader.fromParams({ + 'attributes_config': request.attributesConfig ?? '', + }); + this.initialize(); + return this.innerApiCalls.replaceCatalogAttribute(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 {@link google.cloud.retail.v2.Catalog | 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' + ] = this._gaxModule.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 {@link google.cloud.retail.v2.Catalog | 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' + ] = this._gaxModule.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 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 + * {@link google.cloud.retail.v2.Catalog | 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' + ] = this._gaxModule.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 {}, + callSettings + ) as AsyncIterable; + } +/** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + +/** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + +/** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified 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 model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project:string,location:string,catalog:string,model:string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * 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(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-retail/v2/src/v2/catalog_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2/src/v2/catalog_service_client_config.json new file mode 100644 index 00000000000..407c2a8de65 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/src/v2/catalog_service_client_config.json @@ -0,0 +1,90 @@ +{ + "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" + }, + "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/google-cloud-retail/v2/src/v2/catalog_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2/src/v2/catalog_service_proto_list.json new file mode 100644 index 00000000000..b31d21dbd95 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/src/v2/catalog_service_proto_list.json @@ -0,0 +1,21 @@ +[ + "../../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/control.proto", + "../../protos/google/cloud/retail/v2/control_service.proto", + "../../protos/google/cloud/retail/v2/import_config.proto", + "../../protos/google/cloud/retail/v2/model.proto", + "../../protos/google/cloud/retail/v2/model_service.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/serving_config.proto", + "../../protos/google/cloud/retail/v2/serving_config_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/google-cloud-retail/v2/src/v2/completion_service_client.ts b/owl-bot-staging/google-cloud-retail/v2/src/v2/completion_service_client.ts new file mode 100644 index 00000000000..75353b50940 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/src/v2/completion_service_client.ts @@ -0,0 +1,1294 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, LocationsClient, LocationProtos} 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'; +const version = require('../../../package.json').version; + +/** + * Autocomplete service for retail. + * + * This feature is only available for users who have Retail Search enabled. + * 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}; + locationsClient: LocationsClient; + 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/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new CompletionServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof 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); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + 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}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + 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. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2/{name=projects/*/locations/*/operations/*}',additional_bindings: [{get: '/v2/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',},{get: '/v2/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2/{name=projects/*/operations/*}',}], + },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2/{name=projects/*/locations/*}/operations',additional_bindings: [{get: '/v2/{name=projects/*/locations/*/catalogs/*}/operations',},{get: '/v2/{name=projects/*}/operations',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).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 = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.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._opts.fallback + ); + + 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. + * 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 + * Note that this field applies for `user-data` dataset only. For requests + * with `cloud-retail` dataset, setting this field has no effect. + * + * 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. We recommend that you + * leave this field empty. + * + * It can 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 google.cloud.retail.v2.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 {string} request.entity + * The entity for customers that may run multiple different entities, domains, + * sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, + * `google.com`, `youtube.com`, etc. + * If this is set, it should be exactly matched with + * {@link google.cloud.retail.v2.UserEvent.entity|UserEvent.entity} to get + * per-entity autocomplete results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.retail.v2.CompleteQueryResponse | 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' + ] = this._gaxModule.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. + * 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 is sent to + * specified Pub/Sub topic. The message data is 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' + ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.importCompletionData, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + +/** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + +/** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified 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 model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project:string,location:string,catalog:string,model:string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * 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.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-retail/v2/src/v2/completion_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2/src/v2/completion_service_client_config.json new file mode 100644 index 00000000000..a6bffad0d24 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2/src/v2/completion_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2/src/v2/completion_service_proto_list.json new file mode 100644 index 00000000000..b31d21dbd95 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/src/v2/completion_service_proto_list.json @@ -0,0 +1,21 @@ +[ + "../../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/control.proto", + "../../protos/google/cloud/retail/v2/control_service.proto", + "../../protos/google/cloud/retail/v2/import_config.proto", + "../../protos/google/cloud/retail/v2/model.proto", + "../../protos/google/cloud/retail/v2/model_service.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/serving_config.proto", + "../../protos/google/cloud/retail/v2/serving_config_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/google-cloud-retail/v2/src/v2/control_service_client.ts b/owl-bot-staging/google-cloud-retail/v2/src/v2/control_service_client.ts new file mode 100644 index 00000000000..78f749b3fe5 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/src/v2/control_service_client.ts @@ -0,0 +1,1556 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2/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 v2 + */ +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}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + 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/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new ControlServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof 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); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + 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}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + 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') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2/{name=projects/*/locations/*/operations/*}',additional_bindings: [{get: '/v2/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',},{get: '/v2/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2/{name=projects/*/operations/*}',}], + },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2/{name=projects/*/locations/*}/operations',additional_bindings: [{get: '/v2/{name=projects/*/locations/*/catalogs/*}/operations',},{get: '/v2/{name=projects/*}/operations',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + + this.descriptors.longrunning = { + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2.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 = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.controlServiceStub) { + return this.controlServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2.ControlService. + this.controlServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2.ControlService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2.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._opts.fallback + ); + + 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.v2.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.v2.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 {@link google.cloud.retail.v2.Control | 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/v2/control_service.create_control.js + * region_tag:retail_v2_generated_ControlService_CreateControl_async + */ + createControl( + request?: protos.google.cloud.retail.v2.ICreateControlRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2.IControl, + protos.google.cloud.retail.v2.ICreateControlRequest|undefined, {}|undefined + ]>; + createControl( + request: protos.google.cloud.retail.v2.ICreateControlRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IControl, + protos.google.cloud.retail.v2.ICreateControlRequest|null|undefined, + {}|null|undefined>): void; + createControl( + request: protos.google.cloud.retail.v2.ICreateControlRequest, + callback: Callback< + protos.google.cloud.retail.v2.IControl, + protos.google.cloud.retail.v2.ICreateControlRequest|null|undefined, + {}|null|undefined>): void; + createControl( + request?: protos.google.cloud.retail.v2.ICreateControlRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2.IControl, + protos.google.cloud.retail.v2.ICreateControlRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2.IControl, + protos.google.cloud.retail.v2.ICreateControlRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2.IControl, + protos.google.cloud.retail.v2.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' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createControl(request, options, callback); + } +/** + * Deletes a Control. + * + * If the {@link google.cloud.retail.v2.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 {@link google.protobuf.Empty | 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/control_service.delete_control.js + * region_tag:retail_v2_generated_ControlService_DeleteControl_async + */ + deleteControl( + request?: protos.google.cloud.retail.v2.IDeleteControlRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.IDeleteControlRequest|undefined, {}|undefined + ]>; + deleteControl( + request: protos.google.cloud.retail.v2.IDeleteControlRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.IDeleteControlRequest|null|undefined, + {}|null|undefined>): void; + deleteControl( + request: protos.google.cloud.retail.v2.IDeleteControlRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.IDeleteControlRequest|null|undefined, + {}|null|undefined>): void; + deleteControl( + request?: protos.google.cloud.retail.v2.IDeleteControlRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.IDeleteControlRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.IDeleteControlRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.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' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteControl(request, options, callback); + } +/** + * Updates a Control. + * + * {@link google.cloud.retail.v2.Control|Control} cannot be set to a different + * oneof field, if so an INVALID_ARGUMENT is returned. If the + * {@link google.cloud.retail.v2.Control|Control} to update does not exist, a + * NOT_FOUND error is returned. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2.Control} request.control + * Required. The Control to update. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2.Control|Control} to update. The following are NOT + * supported: + * + * * {@link google.cloud.retail.v2.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 {@link google.cloud.retail.v2.Control | 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/v2/control_service.update_control.js + * region_tag:retail_v2_generated_ControlService_UpdateControl_async + */ + updateControl( + request?: protos.google.cloud.retail.v2.IUpdateControlRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2.IControl, + protos.google.cloud.retail.v2.IUpdateControlRequest|undefined, {}|undefined + ]>; + updateControl( + request: protos.google.cloud.retail.v2.IUpdateControlRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IControl, + protos.google.cloud.retail.v2.IUpdateControlRequest|null|undefined, + {}|null|undefined>): void; + updateControl( + request: protos.google.cloud.retail.v2.IUpdateControlRequest, + callback: Callback< + protos.google.cloud.retail.v2.IControl, + protos.google.cloud.retail.v2.IUpdateControlRequest|null|undefined, + {}|null|undefined>): void; + updateControl( + request?: protos.google.cloud.retail.v2.IUpdateControlRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2.IControl, + protos.google.cloud.retail.v2.IUpdateControlRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2.IControl, + protos.google.cloud.retail.v2.IUpdateControlRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2.IControl, + protos.google.cloud.retail.v2.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' + ] = this._gaxModule.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 get. 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 {@link google.cloud.retail.v2.Control | 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/v2/control_service.get_control.js + * region_tag:retail_v2_generated_ControlService_GetControl_async + */ + getControl( + request?: protos.google.cloud.retail.v2.IGetControlRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2.IControl, + protos.google.cloud.retail.v2.IGetControlRequest|undefined, {}|undefined + ]>; + getControl( + request: protos.google.cloud.retail.v2.IGetControlRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IControl, + protos.google.cloud.retail.v2.IGetControlRequest|null|undefined, + {}|null|undefined>): void; + getControl( + request: protos.google.cloud.retail.v2.IGetControlRequest, + callback: Callback< + protos.google.cloud.retail.v2.IControl, + protos.google.cloud.retail.v2.IGetControlRequest|null|undefined, + {}|null|undefined>): void; + getControl( + request?: protos.google.cloud.retail.v2.IGetControlRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2.IControl, + protos.google.cloud.retail.v2.IGetControlRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2.IControl, + protos.google.cloud.retail.v2.IGetControlRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2.IControl, + protos.google.cloud.retail.v2.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' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getControl(request, options, callback); + } + + /** + * Lists all Controls by their parent + * {@link google.cloud.retail.v2.Catalog|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.v2.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 {@link google.cloud.retail.v2.Control | 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.v2.IListControlsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2.IControl[], + protos.google.cloud.retail.v2.IListControlsRequest|null, + protos.google.cloud.retail.v2.IListControlsResponse + ]>; + listControls( + request: protos.google.cloud.retail.v2.IListControlsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2.IListControlsRequest, + protos.google.cloud.retail.v2.IListControlsResponse|null|undefined, + protos.google.cloud.retail.v2.IControl>): void; + listControls( + request: protos.google.cloud.retail.v2.IListControlsRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2.IListControlsRequest, + protos.google.cloud.retail.v2.IListControlsResponse|null|undefined, + protos.google.cloud.retail.v2.IControl>): void; + listControls( + request?: protos.google.cloud.retail.v2.IListControlsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.retail.v2.IListControlsRequest, + protos.google.cloud.retail.v2.IListControlsResponse|null|undefined, + protos.google.cloud.retail.v2.IControl>, + callback?: PaginationCallback< + protos.google.cloud.retail.v2.IListControlsRequest, + protos.google.cloud.retail.v2.IListControlsResponse|null|undefined, + protos.google.cloud.retail.v2.IControl>): + Promise<[ + protos.google.cloud.retail.v2.IControl[], + protos.google.cloud.retail.v2.IListControlsRequest|null, + protos.google.cloud.retail.v2.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' + ] = this._gaxModule.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.v2.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 {@link google.cloud.retail.v2.Control | 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.v2.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' + ] = this._gaxModule.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 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.v2.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 + * {@link google.cloud.retail.v2.Control | 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/v2/control_service.list_controls.js + * region_tag:retail_v2_generated_ControlService_ListControls_async + */ + listControlsAsync( + request?: protos.google.cloud.retail.v2.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' + ] = this._gaxModule.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 {}, + callSettings + ) as AsyncIterable; + } +/** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + +/** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + +/** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified 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 model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project:string,location:string,catalog:string,model:string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * 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(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-retail/v2/src/v2/control_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2/src/v2/control_service_client_config.json new file mode 100644 index 00000000000..004c29452fe --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/src/v2/control_service_client_config.json @@ -0,0 +1,46 @@ +{ + "interfaces": { + "google.cloud.retail.v2.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/google-cloud-retail/v2/src/v2/control_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2/src/v2/control_service_proto_list.json new file mode 100644 index 00000000000..b31d21dbd95 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/src/v2/control_service_proto_list.json @@ -0,0 +1,21 @@ +[ + "../../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/control.proto", + "../../protos/google/cloud/retail/v2/control_service.proto", + "../../protos/google/cloud/retail/v2/import_config.proto", + "../../protos/google/cloud/retail/v2/model.proto", + "../../protos/google/cloud/retail/v2/model_service.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/serving_config.proto", + "../../protos/google/cloud/retail/v2/serving_config_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/google-cloud-retail/v2/src/v2/gapic_metadata.json b/owl-bot-staging/google-cloud-retail/v2/src/v2/gapic_metadata.json new file mode 100644 index 00000000000..78e1ab8635a --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/src/v2/gapic_metadata.json @@ -0,0 +1,669 @@ +{ + "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" + ] + }, + "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" + ] + } + } + } + } + }, + "ModelService": { + "clients": { + "grpc": { + "libraryClient": "ModelServiceClient", + "rpcs": { + "GetModel": { + "methods": [ + "getModel" + ] + }, + "PauseModel": { + "methods": [ + "pauseModel" + ] + }, + "ResumeModel": { + "methods": [ + "resumeModel" + ] + }, + "DeleteModel": { + "methods": [ + "deleteModel" + ] + }, + "UpdateModel": { + "methods": [ + "updateModel" + ] + }, + "CreateModel": { + "methods": [ + "createModel" + ] + }, + "TuneModel": { + "methods": [ + "tuneModel" + ] + }, + "ListModels": { + "methods": [ + "listModels", + "listModelsStream", + "listModelsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ModelServiceClient", + "rpcs": { + "GetModel": { + "methods": [ + "getModel" + ] + }, + "PauseModel": { + "methods": [ + "pauseModel" + ] + }, + "ResumeModel": { + "methods": [ + "resumeModel" + ] + }, + "DeleteModel": { + "methods": [ + "deleteModel" + ] + }, + "UpdateModel": { + "methods": [ + "updateModel" + ] + }, + "CreateModel": { + "methods": [ + "createModel" + ] + }, + "TuneModel": { + "methods": [ + "tuneModel" + ] + }, + "ListModels": { + "methods": [ + "listModels", + "listModelsStream", + "listModelsAsync" + ] + } + } + } + } + }, + "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/google-cloud-retail/v2/src/v2/index.ts b/owl-bot-staging/google-cloud-retail/v2/src/v2/index.ts new file mode 100644 index 00000000000..24ad5baba84 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/src/v2/index.ts @@ -0,0 +1,27 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {ModelServiceClient} from './model_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/google-cloud-retail/v2/src/v2/model_service_client.ts b/owl-bot-staging/google-cloud-retail/v2/src/v2/model_service_client.ts new file mode 100644 index 00000000000..380ddade120 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/src/v2/model_service_client.ts @@ -0,0 +1,1811 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2/model_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './model_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service for performing CRUD operations on models. + * Recommendation models contain all the metadata necessary to generate a set of + * models for the `Predict()` API. A model is queried + * indirectly via a ServingConfig, which associates a model with a + * given Placement (e.g. Frequently Bought Together on Home Page). + * + * This service allows you to do the following: + * + * * Initiate training of a model. + * * Pause training of an existing model. + * * List all the available models along with their metadata. + * * Control their tuning schedule. + * @class + * @memberof v2 + */ +export class ModelServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + modelServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ModelServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new ModelServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ModelServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + 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}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + 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 = { + listModels: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'models') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2/{name=projects/*/locations/*/operations/*}',additional_bindings: [{get: '/v2/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',},{get: '/v2/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2/{name=projects/*/operations/*}',}], + },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2/{name=projects/*/locations/*}/operations',additional_bindings: [{get: '/v2/{name=projects/*/locations/*/catalogs/*}/operations',},{get: '/v2/{name=projects/*}/operations',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const createModelResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2.Model') as gax.protobuf.Type; + const createModelMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2.CreateModelMetadata') as gax.protobuf.Type; + const tuneModelResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2.TuneModelResponse') as gax.protobuf.Type; + const tuneModelMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2.TuneModelMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + createModel: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createModelResponse.decode.bind(createModelResponse), + createModelMetadata.decode.bind(createModelMetadata)), + tuneModel: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + tuneModelResponse.decode.bind(tuneModelResponse), + tuneModelMetadata.decode.bind(tuneModelMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2.ModelService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.modelServiceStub) { + return this.modelServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2.ModelService. + this.modelServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2.ModelService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2.ModelService, + 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 modelServiceStubMethods = + ['createModel', 'getModel', 'pauseModel', 'resumeModel', 'deleteModel', 'listModels', 'updateModel', 'tuneModel']; + for (const methodName of modelServiceStubMethods) { + const callPromise = this.modelServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.modelServiceStub; + } + + /** + * 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 -- + // ------------------- +/** + * Gets a model. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the {@link google.cloud.retail.v2.Model|Model} to + * get. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog}/models/{model_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 {@link google.cloud.retail.v2.Model | Model}. + * Please see 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/model_service.get_model.js + * region_tag:retail_v2_generated_ModelService_GetModel_async + */ + getModel( + request?: protos.google.cloud.retail.v2.IGetModelRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2.IModel, + protos.google.cloud.retail.v2.IGetModelRequest|undefined, {}|undefined + ]>; + getModel( + request: protos.google.cloud.retail.v2.IGetModelRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IModel, + protos.google.cloud.retail.v2.IGetModelRequest|null|undefined, + {}|null|undefined>): void; + getModel( + request: protos.google.cloud.retail.v2.IGetModelRequest, + callback: Callback< + protos.google.cloud.retail.v2.IModel, + protos.google.cloud.retail.v2.IGetModelRequest|null|undefined, + {}|null|undefined>): void; + getModel( + request?: protos.google.cloud.retail.v2.IGetModelRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2.IModel, + protos.google.cloud.retail.v2.IGetModelRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2.IModel, + protos.google.cloud.retail.v2.IGetModelRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2.IModel, + protos.google.cloud.retail.v2.IGetModelRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getModel(request, options, callback); + } +/** + * Pauses the training of an existing model. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the model to pause. + * Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_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 {@link google.cloud.retail.v2.Model | Model}. + * Please see 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/model_service.pause_model.js + * region_tag:retail_v2_generated_ModelService_PauseModel_async + */ + pauseModel( + request?: protos.google.cloud.retail.v2.IPauseModelRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2.IModel, + protos.google.cloud.retail.v2.IPauseModelRequest|undefined, {}|undefined + ]>; + pauseModel( + request: protos.google.cloud.retail.v2.IPauseModelRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IModel, + protos.google.cloud.retail.v2.IPauseModelRequest|null|undefined, + {}|null|undefined>): void; + pauseModel( + request: protos.google.cloud.retail.v2.IPauseModelRequest, + callback: Callback< + protos.google.cloud.retail.v2.IModel, + protos.google.cloud.retail.v2.IPauseModelRequest|null|undefined, + {}|null|undefined>): void; + pauseModel( + request?: protos.google.cloud.retail.v2.IPauseModelRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2.IModel, + protos.google.cloud.retail.v2.IPauseModelRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2.IModel, + protos.google.cloud.retail.v2.IPauseModelRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2.IModel, + protos.google.cloud.retail.v2.IPauseModelRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.pauseModel(request, options, callback); + } +/** + * Resumes the training of an existing model. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the model to resume. + * Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_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 {@link google.cloud.retail.v2.Model | Model}. + * Please see 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/model_service.resume_model.js + * region_tag:retail_v2_generated_ModelService_ResumeModel_async + */ + resumeModel( + request?: protos.google.cloud.retail.v2.IResumeModelRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2.IModel, + protos.google.cloud.retail.v2.IResumeModelRequest|undefined, {}|undefined + ]>; + resumeModel( + request: protos.google.cloud.retail.v2.IResumeModelRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IModel, + protos.google.cloud.retail.v2.IResumeModelRequest|null|undefined, + {}|null|undefined>): void; + resumeModel( + request: protos.google.cloud.retail.v2.IResumeModelRequest, + callback: Callback< + protos.google.cloud.retail.v2.IModel, + protos.google.cloud.retail.v2.IResumeModelRequest|null|undefined, + {}|null|undefined>): void; + resumeModel( + request?: protos.google.cloud.retail.v2.IResumeModelRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2.IModel, + protos.google.cloud.retail.v2.IResumeModelRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2.IModel, + protos.google.cloud.retail.v2.IResumeModelRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2.IModel, + protos.google.cloud.retail.v2.IResumeModelRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.resumeModel(request, options, callback); + } +/** + * Deletes an existing model. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the {@link google.cloud.retail.v2.Model|Model} to + * delete. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_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 {@link google.protobuf.Empty | 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/model_service.delete_model.js + * region_tag:retail_v2_generated_ModelService_DeleteModel_async + */ + deleteModel( + request?: protos.google.cloud.retail.v2.IDeleteModelRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.IDeleteModelRequest|undefined, {}|undefined + ]>; + deleteModel( + request: protos.google.cloud.retail.v2.IDeleteModelRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.IDeleteModelRequest|null|undefined, + {}|null|undefined>): void; + deleteModel( + request: protos.google.cloud.retail.v2.IDeleteModelRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.IDeleteModelRequest|null|undefined, + {}|null|undefined>): void; + deleteModel( + request?: protos.google.cloud.retail.v2.IDeleteModelRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.IDeleteModelRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.IDeleteModelRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.IDeleteModelRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteModel(request, options, callback); + } +/** + * Update of model metadata. Only fields that + * currently can be updated are: `filtering_option` and + * `periodic_tuning_state`. + * If other values are provided, this API method ignores them. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2.Model} request.model + * Required. The body of the updated {@link google.cloud.retail.v2.Model|Model}. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Indicates which fields in the provided 'model' to + * update. If not set, by default updates all fields. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.retail.v2.Model | Model}. + * Please see 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/model_service.update_model.js + * region_tag:retail_v2_generated_ModelService_UpdateModel_async + */ + updateModel( + request?: protos.google.cloud.retail.v2.IUpdateModelRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2.IModel, + protos.google.cloud.retail.v2.IUpdateModelRequest|undefined, {}|undefined + ]>; + updateModel( + request: protos.google.cloud.retail.v2.IUpdateModelRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IModel, + protos.google.cloud.retail.v2.IUpdateModelRequest|null|undefined, + {}|null|undefined>): void; + updateModel( + request: protos.google.cloud.retail.v2.IUpdateModelRequest, + callback: Callback< + protos.google.cloud.retail.v2.IModel, + protos.google.cloud.retail.v2.IUpdateModelRequest|null|undefined, + {}|null|undefined>): void; + updateModel( + request?: protos.google.cloud.retail.v2.IUpdateModelRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2.IModel, + protos.google.cloud.retail.v2.IUpdateModelRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2.IModel, + protos.google.cloud.retail.v2.IUpdateModelRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2.IModel, + protos.google.cloud.retail.v2.IUpdateModelRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'model.name': request.model!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateModel(request, options, callback); + } + +/** + * Creates a new model. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource under which to create the model. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + * @param {google.cloud.retail.v2.Model} request.model + * Required. The payload of the {@link google.cloud.retail.v2.Model|Model} to + * create. + * @param {boolean} [request.dryRun] + * Optional. Whether to run a dry run to validate the request (without + * actually creating the model). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [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/model_service.create_model.js + * region_tag:retail_v2_generated_ModelService_CreateModel_async + */ + createModel( + request?: protos.google.cloud.retail.v2.ICreateModelRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createModel( + request: protos.google.cloud.retail.v2.ICreateModelRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createModel( + request: protos.google.cloud.retail.v2.ICreateModelRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createModel( + request?: protos.google.cloud.retail.v2.ICreateModelRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createModel(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createModel()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [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/model_service.create_model.js + * region_tag:retail_v2_generated_ModelService_CreateModel_async + */ + async checkCreateModelProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createModel, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Tunes an existing model. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the model to tune. + * Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [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/model_service.tune_model.js + * region_tag:retail_v2_generated_ModelService_TuneModel_async + */ + tuneModel( + request?: protos.google.cloud.retail.v2.ITuneModelRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + tuneModel( + request: protos.google.cloud.retail.v2.ITuneModelRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + tuneModel( + request: protos.google.cloud.retail.v2.ITuneModelRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + tuneModel( + request?: protos.google.cloud.retail.v2.ITuneModelRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.tuneModel(request, options, callback); + } +/** + * Check the status of the long running operation returned by `tuneModel()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [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/model_service.tune_model.js + * region_tag:retail_v2_generated_ModelService_TuneModel_async + */ + async checkTuneModelProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.tuneModel, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists all the models linked to this event store. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent for which to list models. + * 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 `ListModels` + * 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 {@link google.cloud.retail.v2.Model | Model}. + * 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 `listModelsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listModels( + request?: protos.google.cloud.retail.v2.IListModelsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2.IModel[], + protos.google.cloud.retail.v2.IListModelsRequest|null, + protos.google.cloud.retail.v2.IListModelsResponse + ]>; + listModels( + request: protos.google.cloud.retail.v2.IListModelsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2.IListModelsRequest, + protos.google.cloud.retail.v2.IListModelsResponse|null|undefined, + protos.google.cloud.retail.v2.IModel>): void; + listModels( + request: protos.google.cloud.retail.v2.IListModelsRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2.IListModelsRequest, + protos.google.cloud.retail.v2.IListModelsResponse|null|undefined, + protos.google.cloud.retail.v2.IModel>): void; + listModels( + request?: protos.google.cloud.retail.v2.IListModelsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.retail.v2.IListModelsRequest, + protos.google.cloud.retail.v2.IListModelsResponse|null|undefined, + protos.google.cloud.retail.v2.IModel>, + callback?: PaginationCallback< + protos.google.cloud.retail.v2.IListModelsRequest, + protos.google.cloud.retail.v2.IListModelsResponse|null|undefined, + protos.google.cloud.retail.v2.IModel>): + Promise<[ + protos.google.cloud.retail.v2.IModel[], + protos.google.cloud.retail.v2.IListModelsRequest|null, + protos.google.cloud.retail.v2.IListModelsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listModels(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 for which to list models. + * 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 `ListModels` + * 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 {@link google.cloud.retail.v2.Model | Model} 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 `listModelsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listModelsStream( + request?: protos.google.cloud.retail.v2.IListModelsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listModels']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listModels.createStream( + this.innerApiCalls.listModels as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listModels`, 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 for which to list models. + * 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 `ListModels` + * 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 + * {@link google.cloud.retail.v2.Model | Model}. 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/model_service.list_models.js + * region_tag:retail_v2_generated_ModelService_ListModels_async + */ + listModelsAsync( + request?: protos.google.cloud.retail.v2.IListModelsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listModels']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listModels.asyncIterate( + this.innerApiCalls['listModels'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } +/** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + +/** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + +/** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified 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 model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project:string,location:string,catalog:string,model:string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * 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.modelServiceStub && !this._terminated) { + return this.modelServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-retail/v2/src/v2/model_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2/src/v2/model_service_client_config.json new file mode 100644 index 00000000000..715c5647056 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/src/v2/model_service_client_config.json @@ -0,0 +1,66 @@ +{ + "interfaces": { + "google.cloud.retail.v2.ModelService": { + "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": { + "CreateModel": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetModel": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "PauseModel": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ResumeModel": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "DeleteModel": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListModels": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateModel": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "TuneModel": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-retail/v2/src/v2/model_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2/src/v2/model_service_proto_list.json new file mode 100644 index 00000000000..b31d21dbd95 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/src/v2/model_service_proto_list.json @@ -0,0 +1,21 @@ +[ + "../../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/control.proto", + "../../protos/google/cloud/retail/v2/control_service.proto", + "../../protos/google/cloud/retail/v2/import_config.proto", + "../../protos/google/cloud/retail/v2/model.proto", + "../../protos/google/cloud/retail/v2/model_service.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/serving_config.proto", + "../../protos/google/cloud/retail/v2/serving_config_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/google-cloud-retail/v2/src/v2/prediction_service_client.ts b/owl-bot-staging/google-cloud-retail/v2/src/v2/prediction_service_client.ts new file mode 100644 index 00000000000..60fcf9c0fae --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/src/v2/prediction_service_client.ts @@ -0,0 +1,1226 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LocationsClient, LocationProtos} 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}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + 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/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new PredictionServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof 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); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + 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}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + 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. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2/{name=projects/*/locations/*/operations/*}',additional_bindings: [{get: '/v2/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',},{get: '/v2/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2/{name=projects/*/operations/*}',}], + },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2/{name=projects/*/locations/*}/operations',additional_bindings: [{get: '/v2/{name=projects/*/locations/*/catalogs/*}/operations',},{get: '/v2/{name=projects/*}/operations',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + + this.descriptors.longrunning = { + }; + + // 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 = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.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._opts.fallback + ); + + 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: + * `{placement=projects/* /locations/global/catalogs/default_catalog/servingConfigs/*}` + * or + * `{placement=projects/* /locations/global/catalogs/default_catalog/placements/*}`. + * We recommend using the `servingConfigs` resource. `placements` is a legacy + * resource. + * The ID of the Recommendations AI serving config or placement. + * Before you can request predictions from your model, you must create at + * least one serving config or placement for it. For more information, see + * [Manage serving configs] + * (https://cloud.google.com/retail/docs/manage-configs). + * + * The full list of available serving configs can be seen at + * https://console.cloud.google.com/ai/retail/catalogs/default_catalog/configs + * @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. 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 + * This field is not used; leave it unset. + * @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 *no* + * results. If instead you want empty result sets to return generic + * (unfiltered) popular products, set `strictFiltering` to False in + * `PredictRequest.params`. Note that the API will never return items with + * storageStatus of "EXPIRED" or "DELETED" regardless of filter choices. + * + * If `filterSyntaxV2` is set to true under the `params` field, then + * attribute-based expressions are expected instead of the above described + * tag-based syntax. Examples: + * + * * (colors: ANY("Red", "Blue")) AND NOT (categories: ANY("Phones")) + * * (availability: ANY("IN_STOCK")) AND + * (colors: ANY("Red") OR categories: ANY("Phones")) + * + * For more information, see + * [Filter recommendations](https://cloud.google.com/retail/docs/filter-recs). + * @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 a 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. + * * `filterSyntaxV2`: Boolean. False by default. If set to true, the `filter` + * field is interpreteted according to the new, attribute-based syntax. + * @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 {@link google.cloud.retail.v2.PredictResponse | 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'placement': request.placement ?? '', + }); + this.initialize(); + return this.innerApiCalls.predict(request, options, callback); + } + +/** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + +/** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + +/** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified 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 model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project:string,location:string,catalog:string,model:string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * 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(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-retail/v2/src/v2/prediction_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2/src/v2/prediction_service_client_config.json new file mode 100644 index 00000000000..9ab95d31a0c --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2/src/v2/prediction_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2/src/v2/prediction_service_proto_list.json new file mode 100644 index 00000000000..b31d21dbd95 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/src/v2/prediction_service_proto_list.json @@ -0,0 +1,21 @@ +[ + "../../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/control.proto", + "../../protos/google/cloud/retail/v2/control_service.proto", + "../../protos/google/cloud/retail/v2/import_config.proto", + "../../protos/google/cloud/retail/v2/model.proto", + "../../protos/google/cloud/retail/v2/model_service.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/serving_config.proto", + "../../protos/google/cloud/retail/v2/serving_config_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/google-cloud-retail/v2/src/v2/product_service_client.ts b/owl-bot-staging/google-cloud-retail/v2/src/v2/product_service_client.ts new file mode 100644 index 00000000000..8c7a285b55b --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/src/v2/product_service_client.ts @@ -0,0 +1,2857 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/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'; +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}; + locationsClient: LocationsClient; + 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/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new ProductServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof 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); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + 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}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + 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. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2/{name=projects/*/locations/*/operations/*}',additional_bindings: [{get: '/v2/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',},{get: '/v2/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2/{name=projects/*/operations/*}',}], + },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2/{name=projects/*/locations/*}/operations',additional_bindings: [{get: '/v2/{name=projects/*/locations/*/catalogs/*}/operations',},{get: '/v2/{name=projects/*}/operations',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).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 = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.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._opts.fallback + ); + + 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 {@link google.cloud.retail.v2.Product | 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' + ] = this._gaxModule.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 {@link google.cloud.retail.v2.Product | 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' + ] = this._gaxModule.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 {@link google.cloud.retail.v2.Product | 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' + ] = this._gaxModule.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 {@link google.protobuf.Empty | 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' + ] = this._gaxModule.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, all fields are updated. + * @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 is sent to + * specified Pub/Sub topic. The message data is 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 `service-@gcp-sa-retail.iam.gserviceaccount.com` has the + * `pubsub.topics.publish` IAM permission on the 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/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' + ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.importProducts, this._gaxModule.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 is 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|ProductService.GetProduct} + * or + * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts}. + * + * When inventory is updated with + * {@link google.cloud.retail.v2.ProductService.CreateProduct|ProductService.CreateProduct} + * and + * {@link google.cloud.retail.v2.ProductService.UpdateProduct|ProductService.UpdateProduct}, + * the specified inventory field value(s) overwrite any existing value(s) + * while ignoring the last update time for this field. Furthermore, the last + * update times for the specified inventory fields are overwritten by the + * times of the + * {@link google.cloud.retail.v2.ProductService.CreateProduct|ProductService.CreateProduct} + * or + * {@link google.cloud.retail.v2.ProductService.UpdateProduct|ProductService.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 is used. + * + * If no inventory fields are set in + * {@link google.cloud.retail.v2.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask}, + * then any existing inventory information is preserved. + * + * Pre-existing inventory information can only be updated with + * {@link google.cloud.retail.v2.ProductService.SetInventory|ProductService.SetInventory}, + * {@link google.cloud.retail.v2.ProductService.AddFulfillmentPlaces|ProductService.AddFulfillmentPlaces}, + * and + * {@link google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces|ProductService.RemoveFulfillmentPlaces}. + * + * The returned {@link google.longrunning.Operation|Operation}s is obsolete after + * one day, and the {@link google.longrunning.Operations.GetOperation|GetOperation} + * API returns `NOT_FOUND` afterwards. + * + * If conflicting updates are issued, the + * {@link google.longrunning.Operation|Operation}s associated with the stale + * updates are not marked as {@link google.longrunning.Operation.done|done} until + * they are obsolete. + * + * @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 google.cloud.retail.v2.Product.name|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 google.cloud.retail.v2.Product.fulfillment_info|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 google.cloud.retail.v2.Product.fulfillment_info|SetInventoryRequest.inventory.fulfillment_info} + * * Checks that only the desired fulfillment info types have empty + * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|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 google.cloud.retail.v2.ProductService.UpdateProduct|ProductService.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' + ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.setInventory, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * It is recommended to use the + * {@link google.cloud.retail.v2.ProductService.AddLocalInventories|ProductService.AddLocalInventories} + * method instead of + * {@link google.cloud.retail.v2.ProductService.AddFulfillmentPlaces|ProductService.AddFulfillmentPlaces}. + * {@link google.cloud.retail.v2.ProductService.AddLocalInventories|ProductService.AddLocalInventories} + * achieves the same results but provides more fine-grained control over + * ingesting local inventory data. + * + * 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|ProductService.GetProduct} + * or + * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts}. + * + * The returned {@link google.longrunning.Operation|Operation}s will be obsolete + * after 1 day, and {@link google.longrunning.Operations.GetOperation|GetOperation} + * API will return NOT_FOUND afterwards. + * + * If conflicting updates are issued, the + * {@link google.longrunning.Operation|Operation}s associated with the stale + * updates will not be marked as {@link google.longrunning.Operation.done|done} + * until being obsolete. + * + * @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.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' + ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.addFulfillmentPlaces, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * It is recommended to use the + * {@link google.cloud.retail.v2.ProductService.RemoveLocalInventories|ProductService.RemoveLocalInventories} + * method instead of + * {@link google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces|ProductService.RemoveFulfillmentPlaces}. + * {@link google.cloud.retail.v2.ProductService.RemoveLocalInventories|ProductService.RemoveLocalInventories} + * achieves the same results but provides more fine-grained control over + * ingesting local inventory data. + * + * 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|ProductService.GetProduct} + * or + * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts}. + * + * The returned {@link google.longrunning.Operation|Operation}s will be obsolete + * after 1 day, and {@link google.longrunning.Operations.GetOperation|GetOperation} + * API will return NOT_FOUND afterwards. + * + * If conflicting updates are issued, the + * {@link google.longrunning.Operation|Operation}s associated with the stale + * updates will not be marked as {@link google.longrunning.Operation.done|done} + * until being obsolete. + * + * @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' + ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.removeFulfillmentPlaces, this._gaxModule.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|ProductService.GetProduct} + * or + * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts}. + * + * Local inventory information can only be modified using this method. + * {@link google.cloud.retail.v2.ProductService.CreateProduct|ProductService.CreateProduct} + * and + * {@link google.cloud.retail.v2.ProductService.UpdateProduct|ProductService.UpdateProduct} + * has no effect on local inventories. + * + * The returned {@link google.longrunning.Operation|Operation}s will be obsolete + * after 1 day, and {@link google.longrunning.Operations.GetOperation|GetOperation} + * API will return NOT_FOUND afterwards. + * + * If conflicting updates are issued, the + * {@link google.longrunning.Operation|Operation}s associated with the stale + * updates will not be marked as {@link google.longrunning.Operation.done|done} + * until being obsolete. + * + * @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' + ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.addLocalInventories, this._gaxModule.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|ProductService.GetProduct} + * or + * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts}. + * + * Local inventory information can only be removed using this method. + * {@link google.cloud.retail.v2.ProductService.CreateProduct|ProductService.CreateProduct} + * and + * {@link google.cloud.retail.v2.ProductService.UpdateProduct|ProductService.UpdateProduct} + * has no effect on local inventories. + * + * The returned {@link google.longrunning.Operation|Operation}s will be obsolete + * after 1 day, and {@link google.longrunning.Operations.GetOperation|GetOperation} + * API will return NOT_FOUND afterwards. + * + * If conflicting updates are issued, the + * {@link google.longrunning.Operation|Operation}s associated with the stale + * updates will not be marked as {@link google.longrunning.Operation.done|done} + * until being obsolete. + * + * @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' + ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.removeLocalInventories, this._gaxModule.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 {@link google.cloud.retail.v2.Product | 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listProducts(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The 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 {@link google.cloud.retail.v2.Product | 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listProducts']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProducts.createStream( + this.innerApiCalls.listProducts as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProducts`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The 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 + * {@link google.cloud.retail.v2.Product | 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listProducts']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProducts.asyncIterate( + this.innerApiCalls['listProducts'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } +/** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + +/** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + +/** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified 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 model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project:string,location:string,catalog:string,model:string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * 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.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-retail/v2/src/v2/product_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2/src/v2/product_service_client_config.json new file mode 100644 index 00000000000..32245ac6134 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2/src/v2/product_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2/src/v2/product_service_proto_list.json new file mode 100644 index 00000000000..b31d21dbd95 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/src/v2/product_service_proto_list.json @@ -0,0 +1,21 @@ +[ + "../../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/control.proto", + "../../protos/google/cloud/retail/v2/control_service.proto", + "../../protos/google/cloud/retail/v2/import_config.proto", + "../../protos/google/cloud/retail/v2/model.proto", + "../../protos/google/cloud/retail/v2/model_service.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/serving_config.proto", + "../../protos/google/cloud/retail/v2/serving_config_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/google-cloud-retail/v2/src/v2/search_service_client.ts b/owl-bot-staging/google-cloud-retail/v2/src/v2/search_service_client.ts new file mode 100644 index 00000000000..40c82dbe8c7 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/src/v2/search_service_client.ts @@ -0,0 +1,2043 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/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. + * 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}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + 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/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new SearchServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof 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); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + 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}' + ), + experimentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/experiments/{experiment}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + 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') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2/{name=projects/*/locations/*/operations/*}',additional_bindings: [{get: '/v2/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',},{get: '/v2/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2/{name=projects/*/operations/*}',}], + },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2/{name=projects/*/locations/*}/operations',additional_bindings: [{get: '/v2/{name=projects/*/locations/*/catalogs/*}/operations',},{get: '/v2/{name=projects/*}/operations',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + + this.descriptors.longrunning = { + }; + + // 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 = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.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._opts.fallback + ); + + 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. + * 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 Retail Search serving config, such as + * `projects/* /locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` + * or the name of the legacy placement resource, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. + * This field is used to identify the serving config 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 200 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 google.cloud.retail.v2.ServingConfig.boost_control_ids|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, 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. + * + * Notice that if both + * {@link google.cloud.retail.v2.ServingConfig.personalization_spec|ServingConfig.personalization_spec} + * and + * {@link google.cloud.retail.v2.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * are set. + * {@link google.cloud.retail.v2.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * will override + * {@link google.cloud.retail.v2.ServingConfig.personalization_spec|ServingConfig.personalization_spec}. + * @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 {string} request.entity + * The entity for customers that may run multiple different entities, domains, + * sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, + * `google.com`, `youtube.com`, etc. + * If this is set, it should be exactly matched with + * {@link google.cloud.retail.v2.UserEvent.entity|UserEvent.entity} to get search + * results boosted by entity. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 {@link google.cloud.retail.v2.SearchResponse.SearchResult | 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' + ] = this._gaxModule.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 Retail Search serving config, such as + * `projects/* /locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` + * or the name of the legacy placement resource, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. + * This field is used to identify the serving config 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 200 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 google.cloud.retail.v2.ServingConfig.boost_control_ids|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, 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. + * + * Notice that if both + * {@link google.cloud.retail.v2.ServingConfig.personalization_spec|ServingConfig.personalization_spec} + * and + * {@link google.cloud.retail.v2.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * are set. + * {@link google.cloud.retail.v2.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * will override + * {@link google.cloud.retail.v2.ServingConfig.personalization_spec|ServingConfig.personalization_spec}. + * @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 {string} request.entity + * The entity for customers that may run multiple different entities, domains, + * sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, + * `google.com`, `youtube.com`, etc. + * If this is set, it should be exactly matched with + * {@link google.cloud.retail.v2.UserEvent.entity|UserEvent.entity} to get search + * results boosted by entity. + * @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 {@link google.cloud.retail.v2.SearchResponse.SearchResult | 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' + ] = this._gaxModule.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 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 Retail Search serving config, such as + * `projects/* /locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` + * or the name of the legacy placement resource, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. + * This field is used to identify the serving config 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 200 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 google.cloud.retail.v2.ServingConfig.boost_control_ids|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, 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. + * + * Notice that if both + * {@link google.cloud.retail.v2.ServingConfig.personalization_spec|ServingConfig.personalization_spec} + * and + * {@link google.cloud.retail.v2.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * are set. + * {@link google.cloud.retail.v2.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * will override + * {@link google.cloud.retail.v2.ServingConfig.personalization_spec|ServingConfig.personalization_spec}. + * @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 {string} request.entity + * The entity for customers that may run multiple different entities, domains, + * sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, + * `google.com`, `youtube.com`, etc. + * If this is set, it should be exactly matched with + * {@link google.cloud.retail.v2.UserEvent.entity|UserEvent.entity} to get search + * results boosted by entity. + * @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 + * {@link google.cloud.retail.v2.SearchResponse.SearchResult | 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' + ] = this._gaxModule.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 {}, + callSettings + ) as AsyncIterable; + } +/** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + +/** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + +/** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified 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 experiment resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} experiment + * @returns {string} Resource name string. + */ + experimentPath(project:string,location:string,catalog:string,experiment:string) { + return this.pathTemplates.experimentPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + experiment: experiment, + }); + } + + /** + * Parse the project from Experiment resource. + * + * @param {string} experimentName + * A fully-qualified path representing Experiment resource. + * @returns {string} A string representing the project. + */ + matchProjectFromExperimentName(experimentName: string) { + return this.pathTemplates.experimentPathTemplate.match(experimentName).project; + } + + /** + * Parse the location from Experiment resource. + * + * @param {string} experimentName + * A fully-qualified path representing Experiment resource. + * @returns {string} A string representing the location. + */ + matchLocationFromExperimentName(experimentName: string) { + return this.pathTemplates.experimentPathTemplate.match(experimentName).location; + } + + /** + * Parse the catalog from Experiment resource. + * + * @param {string} experimentName + * A fully-qualified path representing Experiment resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromExperimentName(experimentName: string) { + return this.pathTemplates.experimentPathTemplate.match(experimentName).catalog; + } + + /** + * Parse the experiment from Experiment resource. + * + * @param {string} experimentName + * A fully-qualified path representing Experiment resource. + * @returns {string} A string representing the experiment. + */ + matchExperimentFromExperimentName(experimentName: string) { + return this.pathTemplates.experimentPathTemplate.match(experimentName).experiment; + } + + /** + * Return a fully-qualified model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project:string,location:string,catalog:string,model:string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * 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(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-retail/v2/src/v2/search_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2/src/v2/search_service_client_config.json new file mode 100644 index 00000000000..5132c12db6d --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2/src/v2/search_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2/src/v2/search_service_proto_list.json new file mode 100644 index 00000000000..b31d21dbd95 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/src/v2/search_service_proto_list.json @@ -0,0 +1,21 @@ +[ + "../../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/control.proto", + "../../protos/google/cloud/retail/v2/control_service.proto", + "../../protos/google/cloud/retail/v2/import_config.proto", + "../../protos/google/cloud/retail/v2/model.proto", + "../../protos/google/cloud/retail/v2/model_service.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/serving_config.proto", + "../../protos/google/cloud/retail/v2/serving_config_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/google-cloud-retail/v2/src/v2/serving_config_service_client.ts b/owl-bot-staging/google-cloud-retail/v2/src/v2/serving_config_service_client.ts new file mode 100644 index 00000000000..c74e80213cf --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/src/v2/serving_config_service_client.ts @@ -0,0 +1,1693 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2/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 v2 + */ +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}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + 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/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new ServingConfigServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof 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); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + 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}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + 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') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2/{name=projects/*/locations/*/operations/*}',additional_bindings: [{get: '/v2/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',},{get: '/v2/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2/{name=projects/*/operations/*}',}], + },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2/{name=projects/*/locations/*}/operations',additional_bindings: [{get: '/v2/{name=projects/*/locations/*/catalogs/*}/operations',},{get: '/v2/{name=projects/*}/operations',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + + this.descriptors.longrunning = { + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2.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 = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.servingConfigServiceStub) { + return this.servingConfigServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2.ServingConfigService. + this.servingConfigServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2.ServingConfigService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2.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._opts.fallback + ); + + 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.v2.ServingConfig|ServingConfig}s are + * allowed in a {@link google.cloud.retail.v2.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.v2.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 {@link google.cloud.retail.v2.ServingConfig | 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/v2/serving_config_service.create_serving_config.js + * region_tag:retail_v2_generated_ServingConfigService_CreateServingConfig_async + */ + createServingConfig( + request?: protos.google.cloud.retail.v2.ICreateServingConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.ICreateServingConfigRequest|undefined, {}|undefined + ]>; + createServingConfig( + request: protos.google.cloud.retail.v2.ICreateServingConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.ICreateServingConfigRequest|null|undefined, + {}|null|undefined>): void; + createServingConfig( + request: protos.google.cloud.retail.v2.ICreateServingConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.ICreateServingConfigRequest|null|undefined, + {}|null|undefined>): void; + createServingConfig( + request?: protos.google.cloud.retail.v2.ICreateServingConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.ICreateServingConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.ICreateServingConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.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' + ] = this._gaxModule.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 {@link google.protobuf.Empty | 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/serving_config_service.delete_serving_config.js + * region_tag:retail_v2_generated_ServingConfigService_DeleteServingConfig_async + */ + deleteServingConfig( + request?: protos.google.cloud.retail.v2.IDeleteServingConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.IDeleteServingConfigRequest|undefined, {}|undefined + ]>; + deleteServingConfig( + request: protos.google.cloud.retail.v2.IDeleteServingConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.IDeleteServingConfigRequest|null|undefined, + {}|null|undefined>): void; + deleteServingConfig( + request: protos.google.cloud.retail.v2.IDeleteServingConfigRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.IDeleteServingConfigRequest|null|undefined, + {}|null|undefined>): void; + deleteServingConfig( + request?: protos.google.cloud.retail.v2.IDeleteServingConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.IDeleteServingConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.IDeleteServingConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2.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' + ] = this._gaxModule.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.v2.ServingConfig} request.servingConfig + * Required. The ServingConfig to update. + * @param {google.protobuf.FieldMask} request.updateMask + * Indicates which fields in the provided + * {@link google.cloud.retail.v2.ServingConfig|ServingConfig} to update. The + * following are NOT supported: + * + * * {@link google.cloud.retail.v2.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 {@link google.cloud.retail.v2.ServingConfig | 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/v2/serving_config_service.update_serving_config.js + * region_tag:retail_v2_generated_ServingConfigService_UpdateServingConfig_async + */ + updateServingConfig( + request?: protos.google.cloud.retail.v2.IUpdateServingConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.IUpdateServingConfigRequest|undefined, {}|undefined + ]>; + updateServingConfig( + request: protos.google.cloud.retail.v2.IUpdateServingConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.IUpdateServingConfigRequest|null|undefined, + {}|null|undefined>): void; + updateServingConfig( + request: protos.google.cloud.retail.v2.IUpdateServingConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.IUpdateServingConfigRequest|null|undefined, + {}|null|undefined>): void; + updateServingConfig( + request?: protos.google.cloud.retail.v2.IUpdateServingConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.IUpdateServingConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.IUpdateServingConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.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' + ] = this._gaxModule.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 {@link google.cloud.retail.v2.ServingConfig | 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/v2/serving_config_service.get_serving_config.js + * region_tag:retail_v2_generated_ServingConfigService_GetServingConfig_async + */ + getServingConfig( + request?: protos.google.cloud.retail.v2.IGetServingConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.IGetServingConfigRequest|undefined, {}|undefined + ]>; + getServingConfig( + request: protos.google.cloud.retail.v2.IGetServingConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.IGetServingConfigRequest|null|undefined, + {}|null|undefined>): void; + getServingConfig( + request: protos.google.cloud.retail.v2.IGetServingConfigRequest, + callback: Callback< + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.IGetServingConfigRequest|null|undefined, + {}|null|undefined>): void; + getServingConfig( + request?: protos.google.cloud.retail.v2.IGetServingConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.IGetServingConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.IGetServingConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.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' + ] = this._gaxModule.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 {@link google.cloud.retail.v2.ServingConfig | 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/v2/serving_config_service.add_control.js + * region_tag:retail_v2_generated_ServingConfigService_AddControl_async + */ + addControl( + request?: protos.google.cloud.retail.v2.IAddControlRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.IAddControlRequest|undefined, {}|undefined + ]>; + addControl( + request: protos.google.cloud.retail.v2.IAddControlRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.IAddControlRequest|null|undefined, + {}|null|undefined>): void; + addControl( + request: protos.google.cloud.retail.v2.IAddControlRequest, + callback: Callback< + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.IAddControlRequest|null|undefined, + {}|null|undefined>): void; + addControl( + request?: protos.google.cloud.retail.v2.IAddControlRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.IAddControlRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.IAddControlRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.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' + ] = this._gaxModule.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 {@link google.cloud.retail.v2.ServingConfig | 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/v2/serving_config_service.remove_control.js + * region_tag:retail_v2_generated_ServingConfigService_RemoveControl_async + */ + removeControl( + request?: protos.google.cloud.retail.v2.IRemoveControlRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.IRemoveControlRequest|undefined, {}|undefined + ]>; + removeControl( + request: protos.google.cloud.retail.v2.IRemoveControlRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.IRemoveControlRequest|null|undefined, + {}|null|undefined>): void; + removeControl( + request: protos.google.cloud.retail.v2.IRemoveControlRequest, + callback: Callback< + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.IRemoveControlRequest|null|undefined, + {}|null|undefined>): void; + removeControl( + request?: protos.google.cloud.retail.v2.IRemoveControlRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.IRemoveControlRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.IRemoveControlRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2.IServingConfig, + protos.google.cloud.retail.v2.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' + ] = this._gaxModule.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 {@link google.cloud.retail.v2.ServingConfig | 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.v2.IListServingConfigsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2.IServingConfig[], + protos.google.cloud.retail.v2.IListServingConfigsRequest|null, + protos.google.cloud.retail.v2.IListServingConfigsResponse + ]>; + listServingConfigs( + request: protos.google.cloud.retail.v2.IListServingConfigsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2.IListServingConfigsRequest, + protos.google.cloud.retail.v2.IListServingConfigsResponse|null|undefined, + protos.google.cloud.retail.v2.IServingConfig>): void; + listServingConfigs( + request: protos.google.cloud.retail.v2.IListServingConfigsRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2.IListServingConfigsRequest, + protos.google.cloud.retail.v2.IListServingConfigsResponse|null|undefined, + protos.google.cloud.retail.v2.IServingConfig>): void; + listServingConfigs( + request?: protos.google.cloud.retail.v2.IListServingConfigsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.retail.v2.IListServingConfigsRequest, + protos.google.cloud.retail.v2.IListServingConfigsResponse|null|undefined, + protos.google.cloud.retail.v2.IServingConfig>, + callback?: PaginationCallback< + protos.google.cloud.retail.v2.IListServingConfigsRequest, + protos.google.cloud.retail.v2.IListServingConfigsResponse|null|undefined, + protos.google.cloud.retail.v2.IServingConfig>): + Promise<[ + protos.google.cloud.retail.v2.IServingConfig[], + protos.google.cloud.retail.v2.IListServingConfigsRequest|null, + protos.google.cloud.retail.v2.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' + ] = this._gaxModule.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 {@link google.cloud.retail.v2.ServingConfig | 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.v2.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' + ] = this._gaxModule.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 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 + * {@link google.cloud.retail.v2.ServingConfig | 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/v2/serving_config_service.list_serving_configs.js + * region_tag:retail_v2_generated_ServingConfigService_ListServingConfigs_async + */ + listServingConfigsAsync( + request?: protos.google.cloud.retail.v2.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' + ] = this._gaxModule.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 {}, + callSettings + ) as AsyncIterable; + } +/** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + +/** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + +/** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified 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 model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project:string,location:string,catalog:string,model:string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * 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(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-retail/v2/src/v2/serving_config_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2/src/v2/serving_config_service_client_config.json new file mode 100644 index 00000000000..3f5419b8c62 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/src/v2/serving_config_service_client_config.json @@ -0,0 +1,54 @@ +{ + "interfaces": { + "google.cloud.retail.v2.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/google-cloud-retail/v2/src/v2/serving_config_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2/src/v2/serving_config_service_proto_list.json new file mode 100644 index 00000000000..b31d21dbd95 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/src/v2/serving_config_service_proto_list.json @@ -0,0 +1,21 @@ +[ + "../../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/control.proto", + "../../protos/google/cloud/retail/v2/control_service.proto", + "../../protos/google/cloud/retail/v2/import_config.proto", + "../../protos/google/cloud/retail/v2/model.proto", + "../../protos/google/cloud/retail/v2/model_service.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/serving_config.proto", + "../../protos/google/cloud/retail/v2/serving_config_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/google-cloud-retail/v2/src/v2/user_event_service_client.ts b/owl-bot-staging/google-cloud-retail/v2/src/v2/user_event_service_client.ts new file mode 100644 index 00000000000..9a7d70026e1 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/src/v2/user_event_service_client.ts @@ -0,0 +1,1559 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, LocationsClient, LocationProtos} 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'; +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}; + locationsClient: LocationsClient; + 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/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new UserEventServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof 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); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + 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}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + 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. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2/{name=projects/*/locations/*/operations/*}',additional_bindings: [{get: '/v2/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',},{get: '/v2/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2/{name=projects/*/operations/*}',}], + },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2/{name=projects/*/locations/*}/operations',additional_bindings: [{get: '/v2/{name=projects/*/locations/*/catalogs/*}/operations',},{get: '/v2/{name=projects/*}/operations',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).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 = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.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._opts.fallback + ); + + 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 {boolean} request.writeAsync + * If set to true, the user event will be written asynchronously after + * validation, and the API will respond without waiting for the write. + * Therefore, silent failures can occur even if the API returns success. In + * case of silent failures, error messages can be found in Stackdriver logs. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.retail.v2.UserEvent | 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' + ] = this._gaxModule.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.prebuiltRule + * The prebuilt rule name that can convert a specific type of raw_json. + * For example: "ga4_bq" rule for the GA4 user event schema. + * @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 {string} request.rawJson + * An arbitrary serialized JSON string that contains necessary information + * that can comprise a user event. When this field is specified, the + * user_event field will be ignored. Note: line-delimited JSON is not + * supported, a single JSON only. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.api.HttpBody | 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' + ] = this._gaxModule.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' + ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.purgeUserEvents, this._gaxModule.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' + ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.importUserEvents, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Starts a user-event rejoin operation with latest product catalog. Events + * are not annotated with detailed product information for products that are + * missing from the catalog when the user event is ingested. These + * events are stored as unjoined events with limited usage on training and + * serving. You can use this method to start a join operation on specified + * events with the latest version of product catalog. You can also use this + * method 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' + ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.rejoinUserEvents, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + +/** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + +/** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified 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 model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project:string,location:string,catalog:string,model:string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * 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.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-retail/v2/src/v2/user_event_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2/src/v2/user_event_service_client_config.json new file mode 100644 index 00000000000..a3938b37468 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2/src/v2/user_event_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2/src/v2/user_event_service_proto_list.json new file mode 100644 index 00000000000..b31d21dbd95 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/src/v2/user_event_service_proto_list.json @@ -0,0 +1,21 @@ +[ + "../../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/control.proto", + "../../protos/google/cloud/retail/v2/control_service.proto", + "../../protos/google/cloud/retail/v2/import_config.proto", + "../../protos/google/cloud/retail/v2/model.proto", + "../../protos/google/cloud/retail/v2/model_service.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/serving_config.proto", + "../../protos/google/cloud/retail/v2/serving_config_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/google-cloud-retail/v2/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-retail/v2/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..b0a6d36778b --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/system-test/fixtures/sample/src/index.js @@ -0,0 +1,35 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 modelServiceClient = new retail.ModelServiceClient(); + 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/google-cloud-retail/v2/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-retail/v2/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..7ee871ea668 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,80 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This 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, ModelServiceClient, 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 doStuffWithModelServiceClient(client: ModelServiceClient) { + 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 modelServiceClient = new ModelServiceClient(); + doStuffWithModelServiceClient(modelServiceClient); + // 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/google-cloud-retail/v2/system-test/install.ts b/owl-bot-staging/google-cloud-retail/v2/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {packNTest} from 'pack-n-play'; +import {readFileSync} from 'fs'; +import {describe, it} from 'mocha'; + +describe('📦 pack-n-play test', () => { + + it('TypeScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'TypeScript user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); + }); + + it('JavaScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'JavaScript user can use the library', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); + }); + +}); diff --git a/owl-bot-staging/google-cloud-retail/v2/test/gapic_catalog_service_v2.ts b/owl-bot-staging/google-cloud-retail/v2/test/gapic_catalog_service_v2.ts new file mode 100644 index 00000000000..9cbde11b68b --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/test/gapic_catalog_service_v2.ts @@ -0,0 +1,2412 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This 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, operationsProtos, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function 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', () => { + describe('Common methods', () => { + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.UpdateCatalogRequest', ['catalog', 'name']); + request.catalog.name = defaultValue1; + const expectedHeaderRequestParams = `catalog.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.updateCatalog as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateCatalog as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.UpdateCatalogRequest', ['catalog', 'name']); + request.catalog.name = defaultValue1; + const expectedHeaderRequestParams = `catalog.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.updateCatalog as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateCatalog as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.UpdateCatalogRequest', ['catalog', 'name']); + request.catalog.name = defaultValue1; + const expectedHeaderRequestParams = `catalog.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCatalog = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateCatalog(request), expectedError); + const actualRequest = (client.innerApiCalls.updateCatalog as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateCatalog as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.UpdateCatalogRequest', ['catalog', 'name']); + request.catalog.name = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.SetDefaultBranchRequest', ['catalog']); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.setDefaultBranch = stubSimpleCall(expectedResponse); + const [response] = await client.setDefaultBranch(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setDefaultBranch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setDefaultBranch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.SetDefaultBranchRequest', ['catalog']); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.setDefaultBranch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setDefaultBranch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.SetDefaultBranchRequest', ['catalog']); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setDefaultBranch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setDefaultBranch(request), expectedError); + const actualRequest = (client.innerApiCalls.setDefaultBranch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setDefaultBranch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.SetDefaultBranchRequest', ['catalog']); + request.catalog = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.GetDefaultBranchRequest', ['catalog']); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getDefaultBranch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDefaultBranch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.GetDefaultBranchRequest', ['catalog']); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getDefaultBranch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDefaultBranch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.GetDefaultBranchRequest', ['catalog']); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getDefaultBranch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getDefaultBranch(request), expectedError); + const actualRequest = (client.innerApiCalls.getDefaultBranch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDefaultBranch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.GetDefaultBranchRequest', ['catalog']); + request.catalog = defaultValue1; + 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.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.GetCompletionConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.GetCompletionConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.CompletionConfig() + ); + client.innerApiCalls.getCompletionConfig = stubSimpleCall(expectedResponse); + const [response] = await client.getCompletionConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getCompletionConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getCompletionConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getCompletionConfig 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.GetCompletionConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.GetCompletionConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.CompletionConfig() + ); + client.innerApiCalls.getCompletionConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getCompletionConfig( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2.ICompletionConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getCompletionConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getCompletionConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getCompletionConfig 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.GetCompletionConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.GetCompletionConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getCompletionConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getCompletionConfig(request), expectedError); + const actualRequest = (client.innerApiCalls.getCompletionConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getCompletionConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getCompletionConfig 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.GetCompletionConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.GetCompletionConfigRequest', ['name']); + request.name = defaultValue1; + 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.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.UpdateCompletionConfigRequest() + ); + request.completionConfig ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.UpdateCompletionConfigRequest', ['completionConfig', 'name']); + request.completionConfig.name = defaultValue1; + const expectedHeaderRequestParams = `completion_config.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.CompletionConfig() + ); + client.innerApiCalls.updateCompletionConfig = stubSimpleCall(expectedResponse); + const [response] = await client.updateCompletionConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateCompletionConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateCompletionConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCompletionConfig 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.UpdateCompletionConfigRequest() + ); + request.completionConfig ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.UpdateCompletionConfigRequest', ['completionConfig', 'name']); + request.completionConfig.name = defaultValue1; + const expectedHeaderRequestParams = `completion_config.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.CompletionConfig() + ); + client.innerApiCalls.updateCompletionConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateCompletionConfig( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2.ICompletionConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateCompletionConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateCompletionConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCompletionConfig 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.UpdateCompletionConfigRequest() + ); + request.completionConfig ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.UpdateCompletionConfigRequest', ['completionConfig', 'name']); + request.completionConfig.name = defaultValue1; + const expectedHeaderRequestParams = `completion_config.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCompletionConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateCompletionConfig(request), expectedError); + const actualRequest = (client.innerApiCalls.updateCompletionConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateCompletionConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCompletionConfig 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.UpdateCompletionConfigRequest() + ); + request.completionConfig ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.UpdateCompletionConfigRequest', ['completionConfig', 'name']); + request.completionConfig.name = defaultValue1; + 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.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.GetAttributesConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.GetAttributesConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.AttributesConfig() + ); + client.innerApiCalls.getAttributesConfig = stubSimpleCall(expectedResponse); + const [response] = await client.getAttributesConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getAttributesConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getAttributesConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getAttributesConfig 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.GetAttributesConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.GetAttributesConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.AttributesConfig() + ); + client.innerApiCalls.getAttributesConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getAttributesConfig( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2.IAttributesConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getAttributesConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getAttributesConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getAttributesConfig 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.GetAttributesConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.GetAttributesConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getAttributesConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getAttributesConfig(request), expectedError); + const actualRequest = (client.innerApiCalls.getAttributesConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getAttributesConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getAttributesConfig 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.GetAttributesConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.GetAttributesConfigRequest', ['name']); + request.name = defaultValue1; + 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.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.UpdateAttributesConfigRequest() + ); + request.attributesConfig ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.UpdateAttributesConfigRequest', ['attributesConfig', 'name']); + request.attributesConfig.name = defaultValue1; + const expectedHeaderRequestParams = `attributes_config.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.AttributesConfig() + ); + client.innerApiCalls.updateAttributesConfig = stubSimpleCall(expectedResponse); + const [response] = await client.updateAttributesConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateAttributesConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateAttributesConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateAttributesConfig 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.UpdateAttributesConfigRequest() + ); + request.attributesConfig ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.UpdateAttributesConfigRequest', ['attributesConfig', 'name']); + request.attributesConfig.name = defaultValue1; + const expectedHeaderRequestParams = `attributes_config.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.AttributesConfig() + ); + client.innerApiCalls.updateAttributesConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateAttributesConfig( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2.IAttributesConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateAttributesConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateAttributesConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateAttributesConfig 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.UpdateAttributesConfigRequest() + ); + request.attributesConfig ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.UpdateAttributesConfigRequest', ['attributesConfig', 'name']); + request.attributesConfig.name = defaultValue1; + const expectedHeaderRequestParams = `attributes_config.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateAttributesConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateAttributesConfig(request), expectedError); + const actualRequest = (client.innerApiCalls.updateAttributesConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateAttributesConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateAttributesConfig 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.UpdateAttributesConfigRequest() + ); + request.attributesConfig ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.UpdateAttributesConfigRequest', ['attributesConfig', 'name']); + request.attributesConfig.name = defaultValue1; + 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.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.AddCatalogAttributeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.AddCatalogAttributeRequest', ['attributesConfig']); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.AttributesConfig() + ); + client.innerApiCalls.addCatalogAttribute = stubSimpleCall(expectedResponse); + const [response] = await client.addCatalogAttribute(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.addCatalogAttribute as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addCatalogAttribute as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addCatalogAttribute 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.AddCatalogAttributeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.AddCatalogAttributeRequest', ['attributesConfig']); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.AttributesConfig() + ); + client.innerApiCalls.addCatalogAttribute = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addCatalogAttribute( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2.IAttributesConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.addCatalogAttribute as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addCatalogAttribute as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addCatalogAttribute 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.AddCatalogAttributeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.AddCatalogAttributeRequest', ['attributesConfig']); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addCatalogAttribute = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.addCatalogAttribute(request), expectedError); + const actualRequest = (client.innerApiCalls.addCatalogAttribute as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addCatalogAttribute as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addCatalogAttribute 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.AddCatalogAttributeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.AddCatalogAttributeRequest', ['attributesConfig']); + request.attributesConfig = defaultValue1; + 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.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.RemoveCatalogAttributeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.RemoveCatalogAttributeRequest', ['attributesConfig']); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.AttributesConfig() + ); + client.innerApiCalls.removeCatalogAttribute = stubSimpleCall(expectedResponse); + const [response] = await client.removeCatalogAttribute(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.removeCatalogAttribute as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeCatalogAttribute as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeCatalogAttribute 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.RemoveCatalogAttributeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.RemoveCatalogAttributeRequest', ['attributesConfig']); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.AttributesConfig() + ); + client.innerApiCalls.removeCatalogAttribute = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeCatalogAttribute( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2.IAttributesConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.removeCatalogAttribute as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeCatalogAttribute as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeCatalogAttribute 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.RemoveCatalogAttributeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.RemoveCatalogAttributeRequest', ['attributesConfig']); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeCatalogAttribute = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.removeCatalogAttribute(request), expectedError); + const actualRequest = (client.innerApiCalls.removeCatalogAttribute as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeCatalogAttribute as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeCatalogAttribute 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.RemoveCatalogAttributeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.RemoveCatalogAttributeRequest', ['attributesConfig']); + request.attributesConfig = defaultValue1; + 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.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ReplaceCatalogAttributeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ReplaceCatalogAttributeRequest', ['attributesConfig']); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.AttributesConfig() + ); + client.innerApiCalls.replaceCatalogAttribute = stubSimpleCall(expectedResponse); + const [response] = await client.replaceCatalogAttribute(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.replaceCatalogAttribute as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.replaceCatalogAttribute as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes replaceCatalogAttribute 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.ReplaceCatalogAttributeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ReplaceCatalogAttributeRequest', ['attributesConfig']); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.AttributesConfig() + ); + client.innerApiCalls.replaceCatalogAttribute = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.replaceCatalogAttribute( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2.IAttributesConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.replaceCatalogAttribute as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.replaceCatalogAttribute as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes replaceCatalogAttribute 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.ReplaceCatalogAttributeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ReplaceCatalogAttributeRequest', ['attributesConfig']); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.replaceCatalogAttribute = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.replaceCatalogAttribute(request), expectedError); + const actualRequest = (client.innerApiCalls.replaceCatalogAttribute as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.replaceCatalogAttribute as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes replaceCatalogAttribute 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.ReplaceCatalogAttributeRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ReplaceCatalogAttributeRequest', ['attributesConfig']); + request.attributesConfig = defaultValue1; + 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.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListCatalogsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ListCatalogsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.listCatalogs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listCatalogs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ListCatalogsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.listCatalogs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listCatalogs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ListCatalogsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listCatalogs = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listCatalogs(request), expectedError); + const actualRequest = (client.innerApiCalls.listCatalogs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listCatalogs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ListCatalogsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listCatalogs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ListCatalogsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listCatalogs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ListCatalogsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ListCatalogsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getLocation without error using callback', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getLocation(request, expectedOptions), expectedError); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.getOperation(request)}, expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('attributesConfig', () => { + const fakePath = "/rendered/path/attributesConfig"; + 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.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.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('completionConfig', () => { + const fakePath = "/rendered/path/completionConfig"; + 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.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.v2.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.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('model', () => { + const fakePath = "/rendered/path/model"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + model: "modelValue", + }; + const client = new catalogserviceModule.v2.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.modelPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, "modelValue"); + assert((client.pathTemplates.modelPathTemplate.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)); + }); + }); + + describe('servingConfig', () => { + const fakePath = "/rendered/path/servingConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + serving_config: "servingConfigValue", + }; + const client = new catalogserviceModule.v2.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/google-cloud-retail/v2/test/gapic_completion_service_v2.ts b/owl-bot-staging/google-cloud-retail/v2/test/gapic_completion_service_v2.ts new file mode 100644 index 00000000000..242e0195541 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/test/gapic_completion_service_v2.ts @@ -0,0 +1,1234 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This 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, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function 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.CompletionServiceClient', () => { + describe('Common methods', () => { + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.CompleteQueryRequest', ['catalog']); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.CompleteQueryRequest', ['catalog']); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.CompleteQueryRequest', ['catalog']); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.completeQuery = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.completeQuery(request), expectedError); + const actualRequest = (client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.CompleteQueryRequest', ['catalog']); + request.catalog = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ImportCompletionDataRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.importCompletionData as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importCompletionData as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ImportCompletionDataRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.importCompletionData as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importCompletionData as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ImportCompletionDataRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importCompletionData = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importCompletionData(request), expectedError); + const actualRequest = (client.innerApiCalls.importCompletionData as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importCompletionData as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ImportCompletionDataRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importCompletionData = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importCompletionData(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.importCompletionData as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importCompletionData as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getLocation without error using callback', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getLocation(request, expectedOptions), expectedError); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.getOperation(request)}, expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('attributesConfig', () => { + const fakePath = "/rendered/path/attributesConfig"; + 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.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.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('completionConfig', () => { + const fakePath = "/rendered/path/completionConfig"; + 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.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.v2.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('model', () => { + const fakePath = "/rendered/path/model"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + model: "modelValue", + }; + const client = new completionserviceModule.v2.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.modelPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, "modelValue"); + assert((client.pathTemplates.modelPathTemplate.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)); + }); + }); + + describe('servingConfig', () => { + const fakePath = "/rendered/path/servingConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + serving_config: "servingConfigValue", + }; + const client = new completionserviceModule.v2.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/google-cloud-retail/v2/test/gapic_control_service_v2.ts b/owl-bot-staging/google-cloud-retail/v2/test/gapic_control_service_v2.ts new file mode 100644 index 00000000000..38fb2a6ce12 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/test/gapic_control_service_v2.ts @@ -0,0 +1,1664 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This 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, operationsProtos, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function 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.ControlServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = controlserviceModule.v2.ControlServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = controlserviceModule.v2.ControlServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = controlserviceModule.v2.ControlServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new controlserviceModule.v2.ControlServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new controlserviceModule.v2.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.v2.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.v2.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.v2.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.v2.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.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.CreateControlRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.CreateControlRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.Control() + ); + client.innerApiCalls.createControl = stubSimpleCall(expectedResponse); + const [response] = await client.createControl(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createControl without error using callback', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.CreateControlRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.CreateControlRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.Control() + ); + client.innerApiCalls.createControl = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createControl( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2.IControl|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createControl with error', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.CreateControlRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.CreateControlRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createControl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createControl(request), expectedError); + const actualRequest = (client.innerApiCalls.createControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createControl with closed client', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.CreateControlRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.CreateControlRequest', ['parent']); + request.parent = defaultValue1; + 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.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.DeleteControlRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.DeleteControlRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteControl = stubSimpleCall(expectedResponse); + const [response] = await client.deleteControl(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteControl without error using callback', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.DeleteControlRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.DeleteControlRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.deleteControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteControl with error', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.DeleteControlRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.DeleteControlRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteControl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteControl(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteControl with closed client', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.DeleteControlRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.DeleteControlRequest', ['name']); + request.name = defaultValue1; + 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.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.UpdateControlRequest() + ); + request.control ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.UpdateControlRequest', ['control', 'name']); + request.control.name = defaultValue1; + const expectedHeaderRequestParams = `control.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.Control() + ); + client.innerApiCalls.updateControl = stubSimpleCall(expectedResponse); + const [response] = await client.updateControl(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateControl without error using callback', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.UpdateControlRequest() + ); + request.control ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.UpdateControlRequest', ['control', 'name']); + request.control.name = defaultValue1; + const expectedHeaderRequestParams = `control.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.Control() + ); + client.innerApiCalls.updateControl = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateControl( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2.IControl|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateControl with error', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.UpdateControlRequest() + ); + request.control ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.UpdateControlRequest', ['control', 'name']); + request.control.name = defaultValue1; + const expectedHeaderRequestParams = `control.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateControl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateControl(request), expectedError); + const actualRequest = (client.innerApiCalls.updateControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateControl with closed client', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.UpdateControlRequest() + ); + request.control ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.UpdateControlRequest', ['control', 'name']); + request.control.name = defaultValue1; + 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.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.GetControlRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.GetControlRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.Control() + ); + client.innerApiCalls.getControl = stubSimpleCall(expectedResponse); + const [response] = await client.getControl(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getControl without error using callback', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.GetControlRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.GetControlRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.Control() + ); + client.innerApiCalls.getControl = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getControl( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2.IControl|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getControl with error', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.GetControlRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.GetControlRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getControl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getControl(request), expectedError); + const actualRequest = (client.innerApiCalls.getControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getControl with closed client', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.GetControlRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.GetControlRequest', ['name']); + request.name = defaultValue1; + 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.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListControlsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ListControlsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2.Control()), + ]; + client.innerApiCalls.listControls = stubSimpleCall(expectedResponse); + const [response] = await client.listControls(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listControls as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listControls as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listControls without error using callback', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListControlsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ListControlsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2.Control()), + ]; + client.innerApiCalls.listControls = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listControls( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2.IControl[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listControls as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listControls as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listControls with error', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListControlsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ListControlsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listControls = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listControls(request), expectedError); + const actualRequest = (client.innerApiCalls.listControls as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listControls as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listControlsStream without error', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListControlsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ListControlsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2.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.v2.Control[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2.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( + (client.descriptors.page.listControls.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listControlsStream with error', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListControlsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ListControlsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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.v2.Control[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2.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( + (client.descriptors.page.listControls.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listControls without error', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListControlsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ListControlsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2.Control()), + generateSampleMessage(new protos.google.cloud.retail.v2.Control()), + ]; + client.descriptors.page.listControls.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2.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( + (client.descriptors.page.listControls.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listControls with error', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListControlsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ListControlsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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.v2.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( + (client.descriptors.page.listControls.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getLocation without error using callback', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getLocation(request, expectedOptions), expectedError); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.getOperation(request)}, expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('attributesConfig', () => { + const fakePath = "/rendered/path/attributesConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new controlserviceModule.v2.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.v2.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.v2.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.v2.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('model', () => { + const fakePath = "/rendered/path/model"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + model: "modelValue", + }; + const client = new controlserviceModule.v2.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.modelPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, "modelValue"); + assert((client.pathTemplates.modelPathTemplate.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.v2.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.v2.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/google-cloud-retail/v2/test/gapic_model_service_v2.ts b/owl-bot-staging/google-cloud-retail/v2/test/gapic_model_service_v2.ts new file mode 100644 index 00000000000..bdef352c886 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/test/gapic_model_service_v2.ts @@ -0,0 +1,2096 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This 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 modelserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v2.ModelServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = modelserviceModule.v2.ModelServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = modelserviceModule.v2.ModelServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = modelserviceModule.v2.ModelServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new modelserviceModule.v2.ModelServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.modelServiceStub, undefined); + await client.initialize(); + assert(client.modelServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.modelServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.modelServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new modelserviceModule.v2.ModelServiceClient({ + 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 modelserviceModule.v2.ModelServiceClient({ + 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('getModel', () => { + it('invokes getModel without error', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.GetModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.GetModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.Model() + ); + client.innerApiCalls.getModel = stubSimpleCall(expectedResponse); + const [response] = await client.getModel(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getModel without error using callback', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.GetModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.GetModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.Model() + ); + client.innerApiCalls.getModel = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getModel( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2.IModel|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getModel with error', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.GetModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.GetModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getModel = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getModel(request), expectedError); + const actualRequest = (client.innerApiCalls.getModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getModel with closed client', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.GetModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.GetModelRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getModel(request), expectedError); + }); + }); + + describe('pauseModel', () => { + it('invokes pauseModel without error', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.PauseModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.PauseModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.Model() + ); + client.innerApiCalls.pauseModel = stubSimpleCall(expectedResponse); + const [response] = await client.pauseModel(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.pauseModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.pauseModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pauseModel without error using callback', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.PauseModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.PauseModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.Model() + ); + client.innerApiCalls.pauseModel = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.pauseModel( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2.IModel|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.pauseModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.pauseModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pauseModel with error', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.PauseModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.PauseModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.pauseModel = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.pauseModel(request), expectedError); + const actualRequest = (client.innerApiCalls.pauseModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.pauseModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pauseModel with closed client', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.PauseModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.PauseModelRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.pauseModel(request), expectedError); + }); + }); + + describe('resumeModel', () => { + it('invokes resumeModel without error', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ResumeModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ResumeModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.Model() + ); + client.innerApiCalls.resumeModel = stubSimpleCall(expectedResponse); + const [response] = await client.resumeModel(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.resumeModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resumeModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resumeModel without error using callback', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ResumeModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ResumeModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.Model() + ); + client.innerApiCalls.resumeModel = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.resumeModel( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2.IModel|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.resumeModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resumeModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resumeModel with error', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ResumeModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ResumeModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resumeModel = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.resumeModel(request), expectedError); + const actualRequest = (client.innerApiCalls.resumeModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resumeModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resumeModel with closed client', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ResumeModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ResumeModelRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.resumeModel(request), expectedError); + }); + }); + + describe('deleteModel', () => { + it('invokes deleteModel without error', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.DeleteModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.DeleteModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteModel = stubSimpleCall(expectedResponse); + const [response] = await client.deleteModel(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteModel without error using callback', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.DeleteModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.DeleteModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteModel = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteModel( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteModel with error', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.DeleteModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.DeleteModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteModel = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteModel(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteModel with closed client', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.DeleteModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.DeleteModelRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteModel(request), expectedError); + }); + }); + + describe('updateModel', () => { + it('invokes updateModel without error', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.UpdateModelRequest() + ); + request.model ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.UpdateModelRequest', ['model', 'name']); + request.model.name = defaultValue1; + const expectedHeaderRequestParams = `model.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.Model() + ); + client.innerApiCalls.updateModel = stubSimpleCall(expectedResponse); + const [response] = await client.updateModel(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateModel without error using callback', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.UpdateModelRequest() + ); + request.model ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.UpdateModelRequest', ['model', 'name']); + request.model.name = defaultValue1; + const expectedHeaderRequestParams = `model.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.Model() + ); + client.innerApiCalls.updateModel = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateModel( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2.IModel|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateModel with error', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.UpdateModelRequest() + ); + request.model ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.UpdateModelRequest', ['model', 'name']); + request.model.name = defaultValue1; + const expectedHeaderRequestParams = `model.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateModel = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateModel(request), expectedError); + const actualRequest = (client.innerApiCalls.updateModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateModel with closed client', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.UpdateModelRequest() + ); + request.model ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.UpdateModelRequest', ['model', 'name']); + request.model.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateModel(request), expectedError); + }); + }); + + describe('createModel', () => { + it('invokes createModel without error', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.CreateModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.CreateModelRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createModel = stubLongRunningCall(expectedResponse); + const [operation] = await client.createModel(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createModel without error using callback', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.CreateModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.CreateModelRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createModel = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createModel( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createModel with call error', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.CreateModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.CreateModelRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createModel = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createModel(request), expectedError); + const actualRequest = (client.innerApiCalls.createModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createModel with LRO error', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.CreateModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.CreateModelRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createModel = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createModel(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.createModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateModelProgress without error', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateModelProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateModelProgress with error', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCreateModelProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('tuneModel', () => { + it('invokes tuneModel without error', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.TuneModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.TuneModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.tuneModel = stubLongRunningCall(expectedResponse); + const [operation] = await client.tuneModel(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.tuneModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.tuneModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes tuneModel without error using callback', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.TuneModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.TuneModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.tuneModel = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.tuneModel( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.tuneModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.tuneModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes tuneModel with call error', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.TuneModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.TuneModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.tuneModel = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.tuneModel(request), expectedError); + const actualRequest = (client.innerApiCalls.tuneModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.tuneModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes tuneModel with LRO error', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.TuneModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.TuneModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.tuneModel = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.tuneModel(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.tuneModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.tuneModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkTuneModelProgress without error', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkTuneModelProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkTuneModelProgress with error', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkTuneModelProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listModels', () => { + it('invokes listModels without error', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListModelsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ListModelsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.Model()), + generateSampleMessage(new protos.google.cloud.retail.v2.Model()), + generateSampleMessage(new protos.google.cloud.retail.v2.Model()), + ]; + client.innerApiCalls.listModels = stubSimpleCall(expectedResponse); + const [response] = await client.listModels(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listModels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listModels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listModels without error using callback', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListModelsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ListModelsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.Model()), + generateSampleMessage(new protos.google.cloud.retail.v2.Model()), + generateSampleMessage(new protos.google.cloud.retail.v2.Model()), + ]; + client.innerApiCalls.listModels = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listModels( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2.IModel[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listModels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listModels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listModels with error', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListModelsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ListModelsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listModels = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listModels(request), expectedError); + const actualRequest = (client.innerApiCalls.listModels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listModels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listModelsStream without error', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListModelsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ListModelsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.Model()), + generateSampleMessage(new protos.google.cloud.retail.v2.Model()), + generateSampleMessage(new protos.google.cloud.retail.v2.Model()), + ]; + client.descriptors.page.listModels.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listModelsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2.Model[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2.Model) => { + 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.listModels.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listModels, request)); + assert( + (client.descriptors.page.listModels.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listModelsStream with error', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListModelsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ListModelsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listModels.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listModelsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2.Model[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2.Model) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listModels.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listModels, request)); + assert( + (client.descriptors.page.listModels.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listModels without error', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListModelsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ListModelsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.Model()), + generateSampleMessage(new protos.google.cloud.retail.v2.Model()), + generateSampleMessage(new protos.google.cloud.retail.v2.Model()), + ]; + client.descriptors.page.listModels.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2.IModel[] = []; + const iterable = client.listModelsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listModels.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listModels.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listModels with error', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListModelsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ListModelsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listModels.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listModelsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.retail.v2.IModel[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listModels.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listModels.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getLocation without error using callback', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getLocation(request, expectedOptions), expectedError); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.getOperation(request)}, expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('attributesConfig', () => { + const fakePath = "/rendered/path/attributesConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new modelserviceModule.v2.ModelServiceClient({ + 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 modelserviceModule.v2.ModelServiceClient({ + 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 modelserviceModule.v2.ModelServiceClient({ + 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 modelserviceModule.v2.ModelServiceClient({ + 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('model', () => { + const fakePath = "/rendered/path/model"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + model: "modelValue", + }; + const client = new modelserviceModule.v2.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.modelPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, "modelValue"); + assert((client.pathTemplates.modelPathTemplate.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 modelserviceModule.v2.ModelServiceClient({ + 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 modelserviceModule.v2.ModelServiceClient({ + 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/google-cloud-retail/v2/test/gapic_prediction_service_v2.ts b/owl-bot-staging/google-cloud-retail/v2/test/gapic_prediction_service_v2.ts new file mode 100644 index 00000000000..239984bb843 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/test/gapic_prediction_service_v2.ts @@ -0,0 +1,1064 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This 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, operationsProtos, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function 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.PredictionServiceClient', () => { + describe('Common methods', () => { + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.PredictRequest', ['placement']); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.predict as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.predict as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.PredictRequest', ['placement']); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.predict as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.predict as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.PredictRequest', ['placement']); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.predict = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.predict(request), expectedError); + const actualRequest = (client.innerApiCalls.predict as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.predict as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.PredictRequest', ['placement']); + request.placement = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.predict(request), expectedError); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getLocation without error using callback', async () => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getLocation(request, expectedOptions), expectedError); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.getOperation(request)}, expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('attributesConfig', () => { + const fakePath = "/rendered/path/attributesConfig"; + 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.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.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('completionConfig', () => { + const fakePath = "/rendered/path/completionConfig"; + 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.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.v2.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('model', () => { + const fakePath = "/rendered/path/model"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + model: "modelValue", + }; + const client = new predictionserviceModule.v2.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.modelPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, "modelValue"); + assert((client.pathTemplates.modelPathTemplate.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)); + }); + }); + + describe('servingConfig', () => { + const fakePath = "/rendered/path/servingConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + serving_config: "servingConfigValue", + }; + const client = new predictionserviceModule.v2.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/google-cloud-retail/v2/test/gapic_product_service_v2.ts b/owl-bot-staging/google-cloud-retail/v2/test/gapic_product_service_v2.ts new file mode 100644 index 00000000000..e6afc43d99a --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/test/gapic_product_service_v2.ts @@ -0,0 +1,2662 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This 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, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v2.ProductServiceClient', () => { + describe('Common methods', () => { + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.CreateProductRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProduct without error using callback', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.CreateProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.CreateProductRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProduct with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.CreateProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.CreateProductRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createProduct(request), expectedError); + const actualRequest = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProduct with closed client', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.CreateProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.CreateProductRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createProduct(request), expectedError); + }); + }); + + describe('getProduct', () => { + it('invokes getProduct without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.GetProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProduct without error using callback', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.GetProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProduct with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.GetProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getProduct(request), expectedError); + const actualRequest = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProduct with closed client', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.GetProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getProduct(request), expectedError); + }); + }); + + describe('updateProduct', () => { + it('invokes updateProduct without error', async () => { + const client = new 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.UpdateProductRequest', ['product', 'name']); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProduct without error using callback', async () => { + const client = new 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.UpdateProductRequest', ['product', 'name']); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProduct with error', async () => { + const client = new 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.UpdateProductRequest', ['product', 'name']); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateProduct(request), expectedError); + const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProduct with closed client', async () => { + const client = new 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.UpdateProductRequest', ['product', 'name']); + request.product.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateProduct(request), expectedError); + }); + }); + + describe('deleteProduct', () => { + it('invokes deleteProduct without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.DeleteProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.DeleteProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteProduct = stubSimpleCall(expectedResponse); + const [response] = await client.deleteProduct(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProduct without error using callback', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.DeleteProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.DeleteProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteProduct( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProduct with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.DeleteProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.DeleteProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteProduct(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProduct with closed client', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.DeleteProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.DeleteProductRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteProduct(request), expectedError); + }); + }); + + describe('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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ImportProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.importProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ImportProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.importProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ImportProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importProducts = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importProducts(request), expectedError); + const actualRequest = (client.innerApiCalls.importProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ImportProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importProducts = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importProducts(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.importProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.SetInventoryRequest', ['inventory', 'name']); + request.inventory.name = defaultValue1; + const expectedHeaderRequestParams = `inventory.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.setInventory as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setInventory as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.SetInventoryRequest', ['inventory', 'name']); + request.inventory.name = defaultValue1; + const expectedHeaderRequestParams = `inventory.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.setInventory as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setInventory as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.SetInventoryRequest', ['inventory', 'name']); + request.inventory.name = defaultValue1; + const expectedHeaderRequestParams = `inventory.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setInventory = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.setInventory(request), expectedError); + const actualRequest = (client.innerApiCalls.setInventory as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setInventory as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.SetInventoryRequest', ['inventory', 'name']); + request.inventory.name = defaultValue1; + const expectedHeaderRequestParams = `inventory.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setInventory = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.setInventory(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.setInventory as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setInventory as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.AddFulfillmentPlacesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.AddFulfillmentPlacesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.AddFulfillmentPlacesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.addFulfillmentPlaces(request), expectedError); + const actualRequest = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.AddFulfillmentPlacesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.addFulfillmentPlaces(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.removeFulfillmentPlaces(request), expectedError); + const actualRequest = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.removeFulfillmentPlaces(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.AddLocalInventoriesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.addLocalInventories as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addLocalInventories as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.AddLocalInventoriesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.addLocalInventories as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addLocalInventories as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.AddLocalInventoriesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addLocalInventories = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.addLocalInventories(request), expectedError); + const actualRequest = (client.innerApiCalls.addLocalInventories as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addLocalInventories as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.AddLocalInventoriesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addLocalInventories = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.addLocalInventories(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.addLocalInventories as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addLocalInventories as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.RemoveLocalInventoriesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.removeLocalInventories as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeLocalInventories as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.RemoveLocalInventoriesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.removeLocalInventories as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeLocalInventories as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.RemoveLocalInventoriesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeLocalInventories = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.removeLocalInventories(request), expectedError); + const actualRequest = (client.innerApiCalls.removeLocalInventories as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeLocalInventories as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.RemoveLocalInventoriesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeLocalInventories = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.removeLocalInventories(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.removeLocalInventories as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeLocalInventories as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProducts without error using callback', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProducts with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listProducts = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProducts(request), expectedError); + const actualRequest = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductsStream without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listProductsStream with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProducts.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProductsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.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( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProducts without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProducts with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProductsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.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( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getLocation without error using callback', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getLocation(request, expectedOptions), expectedError); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.getOperation(request)}, expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('attributesConfig', () => { + const fakePath = "/rendered/path/attributesConfig"; + 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.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.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('completionConfig', () => { + const fakePath = "/rendered/path/completionConfig"; + 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.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.v2.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('model', () => { + const fakePath = "/rendered/path/model"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + model: "modelValue", + }; + const client = new productserviceModule.v2.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.modelPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, "modelValue"); + assert((client.pathTemplates.modelPathTemplate.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)); + }); + }); + + describe('servingConfig', () => { + const fakePath = "/rendered/path/servingConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + serving_config: "servingConfigValue", + }; + const client = new productserviceModule.v2.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/google-cloud-retail/v2/test/gapic_search_service_v2.ts b/owl-bot-staging/google-cloud-retail/v2/test/gapic_search_service_v2.ts new file mode 100644 index 00000000000..33ff392da3b --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/test/gapic_search_service_v2.ts @@ -0,0 +1,1336 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This 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, operationsProtos, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function 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', () => { + describe('Common methods', () => { + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.SearchRequest', ['placement']); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.search as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.search as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.SearchRequest', ['placement']); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.search as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.search as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.SearchRequest', ['placement']); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.search = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.search(request), expectedError); + const actualRequest = (client.innerApiCalls.search as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.search as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.SearchRequest', ['placement']); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + 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( + (client.descriptors.page.search.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.SearchRequest', ['placement']); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + 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( + (client.descriptors.page.search.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.SearchRequest', ['placement']); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + 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( + (client.descriptors.page.search.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.SearchRequest', ['placement']); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + 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( + (client.descriptors.page.search.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getLocation without error using callback', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getLocation(request, expectedOptions), expectedError); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.getOperation(request)}, expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('attributesConfig', () => { + const fakePath = "/rendered/path/attributesConfig"; + 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.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.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('completionConfig', () => { + const fakePath = "/rendered/path/completionConfig"; + 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.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.v2.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('experiment', () => { + const fakePath = "/rendered/path/experiment"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + experiment: "experimentValue", + }; + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.experimentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.experimentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('experimentPath', () => { + const result = client.experimentPath("projectValue", "locationValue", "catalogValue", "experimentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.experimentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromExperimentName', () => { + const result = client.matchProjectFromExperimentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.experimentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromExperimentName', () => { + const result = client.matchLocationFromExperimentName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.experimentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromExperimentName', () => { + const result = client.matchCatalogFromExperimentName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.experimentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchExperimentFromExperimentName', () => { + const result = client.matchExperimentFromExperimentName(fakePath); + assert.strictEqual(result, "experimentValue"); + assert((client.pathTemplates.experimentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('model', () => { + const fakePath = "/rendered/path/model"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + model: "modelValue", + }; + const client = new searchserviceModule.v2.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.modelPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, "modelValue"); + assert((client.pathTemplates.modelPathTemplate.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)); + }); + }); + + describe('servingConfig', () => { + const fakePath = "/rendered/path/servingConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + serving_config: "servingConfigValue", + }; + const client = new searchserviceModule.v2.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/google-cloud-retail/v2/test/gapic_serving_config_service_v2.ts b/owl-bot-staging/google-cloud-retail/v2/test/gapic_serving_config_service_v2.ts new file mode 100644 index 00000000000..62e6d0df6ab --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/test/gapic_serving_config_service_v2.ts @@ -0,0 +1,1880 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This 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, operationsProtos, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function 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.ServingConfigServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = servingconfigserviceModule.v2.ServingConfigServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = servingconfigserviceModule.v2.ServingConfigServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = servingconfigserviceModule.v2.ServingConfigServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new servingconfigserviceModule.v2.ServingConfigServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new servingconfigserviceModule.v2.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.v2.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.v2.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.v2.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.v2.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.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.CreateServingConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.CreateServingConfigRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.ServingConfig() + ); + client.innerApiCalls.createServingConfig = stubSimpleCall(expectedResponse); + const [response] = await client.createServingConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createServingConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createServingConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createServingConfig without error using callback', async () => { + const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.CreateServingConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.CreateServingConfigRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.ServingConfig() + ); + client.innerApiCalls.createServingConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createServingConfig( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2.IServingConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createServingConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createServingConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createServingConfig with error', async () => { + const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.CreateServingConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.CreateServingConfigRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createServingConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createServingConfig(request), expectedError); + const actualRequest = (client.innerApiCalls.createServingConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createServingConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createServingConfig with closed client', async () => { + const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.CreateServingConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.CreateServingConfigRequest', ['parent']); + request.parent = defaultValue1; + 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.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.DeleteServingConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.DeleteServingConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteServingConfig = stubSimpleCall(expectedResponse); + const [response] = await client.deleteServingConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteServingConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteServingConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteServingConfig without error using callback', async () => { + const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.DeleteServingConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.DeleteServingConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.deleteServingConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteServingConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteServingConfig with error', async () => { + const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.DeleteServingConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.DeleteServingConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteServingConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteServingConfig(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteServingConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteServingConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteServingConfig with closed client', async () => { + const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.DeleteServingConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.DeleteServingConfigRequest', ['name']); + request.name = defaultValue1; + 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.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.UpdateServingConfigRequest() + ); + request.servingConfig ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.UpdateServingConfigRequest', ['servingConfig', 'name']); + request.servingConfig.name = defaultValue1; + const expectedHeaderRequestParams = `serving_config.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.ServingConfig() + ); + client.innerApiCalls.updateServingConfig = stubSimpleCall(expectedResponse); + const [response] = await client.updateServingConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateServingConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateServingConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateServingConfig without error using callback', async () => { + const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.UpdateServingConfigRequest() + ); + request.servingConfig ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.UpdateServingConfigRequest', ['servingConfig', 'name']); + request.servingConfig.name = defaultValue1; + const expectedHeaderRequestParams = `serving_config.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.ServingConfig() + ); + client.innerApiCalls.updateServingConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateServingConfig( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2.IServingConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateServingConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateServingConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateServingConfig with error', async () => { + const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.UpdateServingConfigRequest() + ); + request.servingConfig ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.UpdateServingConfigRequest', ['servingConfig', 'name']); + request.servingConfig.name = defaultValue1; + const expectedHeaderRequestParams = `serving_config.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateServingConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateServingConfig(request), expectedError); + const actualRequest = (client.innerApiCalls.updateServingConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateServingConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateServingConfig with closed client', async () => { + const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.UpdateServingConfigRequest() + ); + request.servingConfig ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.UpdateServingConfigRequest', ['servingConfig', 'name']); + request.servingConfig.name = defaultValue1; + 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.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.GetServingConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.GetServingConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.ServingConfig() + ); + client.innerApiCalls.getServingConfig = stubSimpleCall(expectedResponse); + const [response] = await client.getServingConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getServingConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getServingConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getServingConfig without error using callback', async () => { + const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.GetServingConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.GetServingConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.ServingConfig() + ); + client.innerApiCalls.getServingConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getServingConfig( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2.IServingConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getServingConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getServingConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getServingConfig with error', async () => { + const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.GetServingConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.GetServingConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getServingConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getServingConfig(request), expectedError); + const actualRequest = (client.innerApiCalls.getServingConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getServingConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getServingConfig with closed client', async () => { + const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.GetServingConfigRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.GetServingConfigRequest', ['name']); + request.name = defaultValue1; + 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.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.AddControlRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.AddControlRequest', ['servingConfig']); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.ServingConfig() + ); + client.innerApiCalls.addControl = stubSimpleCall(expectedResponse); + const [response] = await client.addControl(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.addControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addControl without error using callback', async () => { + const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.AddControlRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.AddControlRequest', ['servingConfig']); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.ServingConfig() + ); + client.innerApiCalls.addControl = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addControl( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2.IServingConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.addControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addControl with error', async () => { + const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.AddControlRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.AddControlRequest', ['servingConfig']); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addControl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.addControl(request), expectedError); + const actualRequest = (client.innerApiCalls.addControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addControl with closed client', async () => { + const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.AddControlRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.AddControlRequest', ['servingConfig']); + request.servingConfig = defaultValue1; + 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.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.RemoveControlRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.RemoveControlRequest', ['servingConfig']); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.ServingConfig() + ); + client.innerApiCalls.removeControl = stubSimpleCall(expectedResponse); + const [response] = await client.removeControl(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.removeControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeControl without error using callback', async () => { + const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.RemoveControlRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.RemoveControlRequest', ['servingConfig']); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2.ServingConfig() + ); + client.innerApiCalls.removeControl = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removeControl( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2.IServingConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.removeControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeControl with error', async () => { + const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.RemoveControlRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.RemoveControlRequest', ['servingConfig']); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeControl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.removeControl(request), expectedError); + const actualRequest = (client.innerApiCalls.removeControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes removeControl with closed client', async () => { + const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.RemoveControlRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.RemoveControlRequest', ['servingConfig']); + request.servingConfig = defaultValue1; + 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.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListServingConfigsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ListServingConfigsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.ServingConfig()), + generateSampleMessage(new protos.google.cloud.retail.v2.ServingConfig()), + generateSampleMessage(new protos.google.cloud.retail.v2.ServingConfig()), + ]; + client.innerApiCalls.listServingConfigs = stubSimpleCall(expectedResponse); + const [response] = await client.listServingConfigs(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listServingConfigs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listServingConfigs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listServingConfigs without error using callback', async () => { + const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListServingConfigsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ListServingConfigsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.ServingConfig()), + generateSampleMessage(new protos.google.cloud.retail.v2.ServingConfig()), + generateSampleMessage(new protos.google.cloud.retail.v2.ServingConfig()), + ]; + client.innerApiCalls.listServingConfigs = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listServingConfigs( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2.IServingConfig[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listServingConfigs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listServingConfigs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listServingConfigs with error', async () => { + const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListServingConfigsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ListServingConfigsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listServingConfigs = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listServingConfigs(request), expectedError); + const actualRequest = (client.innerApiCalls.listServingConfigs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listServingConfigs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listServingConfigsStream without error', async () => { + const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListServingConfigsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ListServingConfigsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.ServingConfig()), + generateSampleMessage(new protos.google.cloud.retail.v2.ServingConfig()), + generateSampleMessage(new protos.google.cloud.retail.v2.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.v2.ServingConfig[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2.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( + (client.descriptors.page.listServingConfigs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listServingConfigsStream with error', async () => { + const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListServingConfigsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ListServingConfigsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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.v2.ServingConfig[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2.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( + (client.descriptors.page.listServingConfigs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listServingConfigs without error', async () => { + const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListServingConfigsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ListServingConfigsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2.ServingConfig()), + generateSampleMessage(new protos.google.cloud.retail.v2.ServingConfig()), + generateSampleMessage(new protos.google.cloud.retail.v2.ServingConfig()), + ]; + client.descriptors.page.listServingConfigs.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2.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( + (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listServingConfigs with error', async () => { + const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2.ListServingConfigsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ListServingConfigsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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.v2.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( + (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getLocation without error using callback', async () => { + const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getLocation(request, expectedOptions), expectedError); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.getOperation(request)}, expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('attributesConfig', () => { + const fakePath = "/rendered/path/attributesConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new servingconfigserviceModule.v2.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.v2.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.v2.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.v2.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('model', () => { + const fakePath = "/rendered/path/model"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + model: "modelValue", + }; + const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.modelPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, "modelValue"); + assert((client.pathTemplates.modelPathTemplate.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.v2.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.v2.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/google-cloud-retail/v2/test/gapic_user_event_service_v2.ts b/owl-bot-staging/google-cloud-retail/v2/test/gapic_user_event_service_v2.ts new file mode 100644 index 00000000000..999cb43900e --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2/test/gapic_user_event_service_v2.ts @@ -0,0 +1,1650 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This 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, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function 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.UserEventServiceClient', () => { + describe('Common methods', () => { + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.WriteUserEventRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.WriteUserEventRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.WriteUserEventRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.writeUserEvent = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.writeUserEvent(request), expectedError); + const actualRequest = (client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.WriteUserEventRequest', ['parent']); + request.parent = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.CollectUserEventRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.api.HttpBody() + ); + client.innerApiCalls.collectUserEvent = stubSimpleCall(expectedResponse); + const [response] = await client.collectUserEvent(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.CollectUserEventRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.CollectUserEventRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.collectUserEvent = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.collectUserEvent(request), expectedError); + const actualRequest = (client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.CollectUserEventRequest', ['parent']); + request.parent = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.PurgeUserEventsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.purgeUserEvents as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.purgeUserEvents as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.PurgeUserEventsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.purgeUserEvents as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.purgeUserEvents as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.PurgeUserEventsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeUserEvents = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.purgeUserEvents(request), expectedError); + const actualRequest = (client.innerApiCalls.purgeUserEvents as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.purgeUserEvents as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.PurgeUserEventsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeUserEvents = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.purgeUserEvents(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.purgeUserEvents as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.purgeUserEvents as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ImportUserEventsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ImportUserEventsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ImportUserEventsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importUserEvents = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importUserEvents(request), expectedError); + const actualRequest = (client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.ImportUserEventsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importUserEvents = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importUserEvents(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.RejoinUserEventsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.rejoinUserEvents as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.rejoinUserEvents as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.RejoinUserEventsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.rejoinUserEvents as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.rejoinUserEvents as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.RejoinUserEventsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.rejoinUserEvents(request), expectedError); + const actualRequest = (client.innerApiCalls.rejoinUserEvents as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.rejoinUserEvents as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2.RejoinUserEventsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.rejoinUserEvents(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.rejoinUserEvents as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.rejoinUserEvents as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getLocation without error using callback', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getLocation(request, expectedOptions), expectedError); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.getOperation(request)}, expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('attributesConfig', () => { + const fakePath = "/rendered/path/attributesConfig"; + 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.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.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('completionConfig', () => { + const fakePath = "/rendered/path/completionConfig"; + 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.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.v2.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('model', () => { + const fakePath = "/rendered/path/model"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + model: "modelValue", + }; + const client = new usereventserviceModule.v2.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.modelPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, "modelValue"); + assert((client.pathTemplates.modelPathTemplate.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)); + }); + }); + + describe('servingConfig', () => { + const fakePath = "/rendered/path/servingConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + serving_config: "servingConfigValue", + }; + const client = new usereventserviceModule.v2.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/google-cloud-retail/v2/tsconfig.json b/owl-bot-staging/google-cloud-retail/v2/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2/webpack.config.js b/owl-bot-staging/google-cloud-retail/v2/webpack.config.js new file mode 100644 index 00000000000..f2c58f2530c --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2alpha/.eslintignore b/owl-bot-staging/google-cloud-retail/v2alpha/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/.eslintrc.json b/owl-bot-staging/google-cloud-retail/v2alpha/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/.gitignore b/owl-bot-staging/google-cloud-retail/v2alpha/.gitignore new file mode 100644 index 00000000000..d4f03a0df2e --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2alpha/.jsdoc.js b/owl-bot-staging/google-cloud-retail/v2alpha/.jsdoc.js new file mode 100644 index 00000000000..66e9db869e8 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 2023 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/retail', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/.mocharc.js b/owl-bot-staging/google-cloud-retail/v2alpha/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/.mocharc.js @@ -0,0 +1,33 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +const config = { + "enable-source-maps": true, + "throw-deprecation": true, + "timeout": 10000 +} +if (process.env.MOCHA_THROW_DEPRECATION === 'false') { + delete config['throw-deprecation']; +} +if (process.env.MOCHA_REPORTER) { + config.reporter = process.env.MOCHA_REPORTER; +} +if (process.env.MOCHA_REPORTER_OUTPUT) { + config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; +} +module.exports = config diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/.prettierrc.js b/owl-bot-staging/google-cloud-retail/v2alpha/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/.prettierrc.js @@ -0,0 +1,22 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/README.md b/owl-bot-staging/google-cloud-retail/v2alpha/README.md new file mode 100644 index 00000000000..822c4573817 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/README.md @@ -0,0 +1 @@ +Retail: Nodejs Client diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/linkinator.config.json b/owl-bot-staging/google-cloud-retail/v2alpha/linkinator.config.json new file mode 100644 index 00000000000..befd23c8633 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2alpha/package.json b/owl-bot-staging/google-cloud-retail/v2alpha/package.json new file mode 100644 index 00000000000..0e5702137b8 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/package.json @@ -0,0 +1,73 @@ +{ + "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", + "merchant center account link service", + "model service", + "prediction service", + "product service", + "search service", + "serving config service", + "user event service" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^3.5.7" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.1", + "jsdoc": "^4.0.0", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.1", + "linkinator": "^4.1.2", + "mocha": "^10.2.0", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.0.1", + "ts-loader": "^8.4.0", + "typescript": "^4.8.4", + "webpack": "^4.46.0", + "webpack-cli": "^4.10.0" + }, + "engines": { + "node": ">=v12" + } +} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/catalog.proto b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/catalog.proto new file mode 100644 index 00000000000..ee569f9c8d7 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/catalog.proto @@ -0,0 +1,477 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; +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` (incompatible with Retail Search): 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 [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.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 [Product + // levels](https://cloud.google.com/retail/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. + 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. + 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. + SEARCHABLE_OPTION_UNSPECIFIED = 0; + + // Searchable option enabled for an attribute. + SEARCHABLE_ENABLED = 1; + + // Searchable option disabled for an attribute. + SEARCHABLE_DISABLED = 2; + } + + // The status of the exact-searchable option of a catalog attribute. + enum ExactSearchableOption { + // Value used when unset. + EXACT_SEARCHABLE_OPTION_UNSPECIFIED = 0; + + // Exact searchable option enabled for an attribute. + EXACT_SEARCHABLE_ENABLED = 1; + + // Exact searchable option disabled for an attribute. + EXACT_SEARCHABLE_DISABLED = 2; + } + + // The status of the retrievable option of a catalog attribute. + enum RetrievableOption { + // Value used when unset. + RETRIEVABLE_OPTION_UNSPECIFIED = 0; + + // Retrievable option enabled for an attribute. + RETRIEVABLE_ENABLED = 1; + + // Retrievable option disabled for an attribute. + RETRIEVABLE_DISABLED = 2; + } + + // Required. Attribute name. + // For example: `color`, `brands`, `attributes.custom_attribute`, such as + // `attributes.xyz`. + // To be indexable, the attribute name can contain only alpha-numeric + // characters and underscores. For example, an attribute named + // `attributes.abc_xyz` can be indexed, but an attribute named + // `attributes.abc-xyz` cannot be indexed. + // + // If the attribute key starts with `attributes.`, then the attribute is a + // custom attribute. Attributes such as `brands`, `patterns`, and `title` are + // built-in and called system attributes. + 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 + // [CatalogService.AddCatalogAttribute][google.cloud.retail.v2alpha.CatalogService.AddCatalogAttribute], + // [CatalogService.ImportCatalogAttributes][google.cloud.retail.v2alpha.CatalogService.ImportCatalogAttributes], + // or + // [CatalogService.UpdateAttributesConfig][google.cloud.retail.v2alpha.CatalogService.UpdateAttributesConfig] + // APIs. This field is `False` for pre-loaded + // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute]s. + // + // Only pre-loaded [catalog + // attributes][google.cloud.retail.v2alpha.CatalogAttribute] that are neither + // in use by products nor predefined can be deleted. [Catalog + // attributes][google.cloud.retail.v2alpha.CatalogAttribute] that are + // either in use by products or are predefined attributes 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]. + // + // Must be specified, otherwise throws INVALID_FORMAT error. + 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. + // + // Must be specified, otherwise throws INVALID_FORMAT error. + 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. + // + // Must be specified, otherwise throws INVALID_FORMAT error. + SearchableOption searchable_option = 7; + + // When + // [AttributesConfig.attribute_config_level][google.cloud.retail.v2alpha.AttributesConfig.attribute_config_level] + // is CATALOG_LEVEL_ATTRIBUTE_CONFIG, if RECOMMENDATIONS_FILTERING_ENABLED, + // attribute values are filterable for recommendations. + // This option works for categorical features only, + // does not work for numerical features, inventory filtering. + RecommendationsFilteringOption recommendations_filtering_option = 8; + + // If EXACT_SEARCHABLE_ENABLED, attribute values will be exact searchable. + // This property only applies to textual custom attributes and requires + // indexable set to enabled to enable exact-searchable. If unset, the server + // behavior defaults to + // [EXACT_SEARCHABLE_DISABLED][google.cloud.retail.v2alpha.CatalogAttribute.ExactSearchableOption.EXACT_SEARCHABLE_DISABLED]. + ExactSearchableOption exact_searchable_option = 11; + + // If RETRIEVABLE_ENABLED, attribute values are retrievable in the search + // results. If unset, the server behavior defaults to + // [RETRIEVABLE_DISABLED][google.cloud.retail.v2alpha.CatalogAttribute.RetrievableOption.RETRIEVABLE_DISABLED]. + RetrievableOption retrievable_option = 12; +} + +// 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. Default + // value is 20. If left unset or set to 0, then will fallback to default + // value. + // + // Value range is 1 to 20. + 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. + // + // Value range is 1 to 20. + 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 source data for the latest import of the autocomplete + // suggestion phrases. + 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 source data for the latest import of the autocomplete + // denylist phrases. + CompletionDataInputConfig denylist_input_config = 7 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Name of the 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 source data for the latest import of the autocomplete + // allowlist phrases. + CompletionDataInputConfig allowlist_input_config = 9 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Name of the 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 is given in [Included + // destination](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; + + // Criteria for the Merchant Center feeds to be ingested via the link. + // All offers will be ingested if the list is empty. + // Otherwise the offers will be ingested from selected feeds. + repeated MerchantCenterFeedFilter feeds = 6; +} + +// Merchant Center Feed filter criterion. +message MerchantCenterFeedFilter { + // Merchant Center primary feed ID. + int64 primary_feed_id = 1; + + // Merchant Center primary feed name. The name is used for the display + // purposes only. + string primary_feed_name = 2; +} + +// 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/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/catalog_service.proto b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/catalog_service.proto new file mode 100644 index 00000000000..41b1af8a3ac --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/catalog_service.proto @@ -0,0 +1,527 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; +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: "*" + }; + } + + // Removes all specified + // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute]s from the + // [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig]. + rpc BatchRemoveCatalogAttributes(BatchRemoveCatalogAttributesRequest) + returns (BatchRemoveCatalogAttributesResponse) { + option (google.api.http) = { + post: "/v2alpha/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:batchRemoveCatalogAttributes" + 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.BatchRemoveCatalogAttributes][google.cloud.retail.v2alpha.CatalogService.BatchRemoveCatalogAttributes] +// method. +message BatchRemoveCatalogAttributesRequest { + // Required. The attributes config resource shared by all catalog attributes + // being deleted. 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 keys of the + // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute]s to + // delete. A maximum of 1000 catalog attributes can be deleted in a batch. + repeated string attribute_keys = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Response of the +// [CatalogService.BatchRemoveCatalogAttributes][google.cloud.retail.v2alpha.CatalogService.BatchRemoveCatalogAttributes]. +message BatchRemoveCatalogAttributesResponse { + // Catalog attributes that were deleted. Only pre-loaded [catalog + // attributes][google.cloud.retail.v2alpha.CatalogAttribute] that are + // neither [in + // use][google.cloud.retail.v2alpha.CatalogAttribute.in_use] by + // products nor predefined can be deleted. + repeated string deleted_catalog_attributes = 1; + + // Catalog attributes that were reset. [Catalog + // attributes][google.cloud.retail.v2alpha.CatalogAttribute] that are either + // [in use][google.cloud.retail.v2alpha.CatalogAttribute.in_use] by products + // or are predefined attributes cannot be deleted; however, their + // configuration properties will reset to default values upon removal request. + repeated string reset_catalog_attributes = 2; +} + +// 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/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/common.proto b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/common.proto new file mode 100644 index 00000000000..276af73c9d2 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/common.proto @@ -0,0 +1,794 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; +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. In this case, server behavior 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; +} + +// If filtering for recommendations is enabled. +enum RecommendationsFilteringOption { + // Value used when unset. + // In this case, server behavior defaults to + // [RECOMMENDATIONS_FILTERING_DISABLED][google.cloud.retail.v2alpha.RecommendationsFilteringOption.RECOMMENDATIONS_FILTERING_DISABLED]. + RECOMMENDATIONS_FILTERING_OPTION_UNSPECIFIED = 0; + + // Recommendation filtering is disabled. + RECOMMENDATIONS_FILTERING_DISABLED = 1; + + // Recommendation filtering is enabled. + RECOMMENDATIONS_FILTERING_ENABLED = 3; +} + +// The use case of Cloud Retail Search. +enum SearchSolutionUseCase { + // The value when it's unspecified. In this case, server behavior defaults to + // [SEARCH_SOLUTION_USE_CASE_SEARCH][google.cloud.retail.v2alpha.SearchSolutionUseCase.SEARCH_SOLUTION_USE_CASE_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. + // For example, "a b c" is 3 terms and allowed, but " a b c d" is 4 terms + // and not allowed for a 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 rules only work for [controls][google.cloud.retail.v2alpha.Control] +// with +// [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2alpha.SolutionType.SOLUTION_TYPE_SEARCH]. +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][google.cloud.retail.v2alpha.Condition.query_terms] + // provided is a global match. + // - 1 or more + // [Condition.query_terms][google.cloud.retail.v2alpha.Condition.query_terms] + // provided are combined with OR operator. + // * Action Input: The request query and filter that are 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][google.cloud.retail.v2alpha.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 75 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 is normally ignored unless + // [AttributesConfig.attribute_config_level][google.cloud.retail.v2alpha.AttributesConfig.attribute_config_level] + // of the [Catalog][google.cloud.retail.v2alpha.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.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 [deprecated = true]; + + // This field is normally ignored unless + // [AttributesConfig.attribute_config_level][google.cloud.retail.v2alpha.AttributesConfig.attribute_config_level] + // of the [Catalog][google.cloud.retail.v2alpha.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.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 [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.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 not be larger than 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. + // 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]. If set, + // [original_price][google.cloud.retail.v2alpha.PriceInfo.original_price] + // should be greater than or equal to + // [price][google.cloud.retail.v2alpha.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.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. 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.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/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/completion_service.proto b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/completion_service.proto new file mode 100644 index 00000000000..61cd99363e3 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/completion_service.proto @@ -0,0 +1,255 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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/search_service.proto"; +import "google/longrunning/operations.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; +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"; + +// Autocomplete service for retail. +// +// This feature is only available for users who have Retail Search enabled. +// 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. + // 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. + // 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" + }; + } +} + +// Autocomplete 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; + + // Note that this field applies for `user-data` dataset only. For requests + // with `cloud-retail` dataset, setting this field has no effect. + // + // 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. We recommend that you + // leave this field empty. + // + // It can 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 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][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; + + // If true, attribute suggestions are enabled and provided in response. + // + // This field is only available for "cloud-retail" dataset. + bool enable_attribute_suggestions = 9; + + // The entity for customers that may run multiple different entities, domains, + // sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, + // `google.com`, `youtube.com`, etc. + // If this is set, it should be exactly matched with + // [UserEvent.entity][google.cloud.retail.v2alpha.UserEvent.entity] to get + // per-entity autocomplete results. + string entity = 10; +} + +// Response of the autocomplete 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. It requires + // [UserEvent.product_details][google.cloud.retail.v2alpha.UserEvent.product_details] + // is imported properly. + map attributes = 2; + + // Facet information for the suggestion term. Gives the number of items + // resulting from a search with this suggestion term for each facet. + // + // This is an experimental feature for limited customers. Please reach out + // to the support team if you would like to receive this information. + repeated SearchResponse.Facet facets = 3; + + // Total number of products associated with a search with this suggestion. + // + // This is an experimental feature for limited customers. Please reach out + // to the support team if you would like to receive this information. + int32 total_product_count = 4; + } + + // Recent search of this user. + message RecentSearchResult { + // The recent search query. + string recent_search = 1; + } + + // Resource that represents attribute results. + message AttributeResult { + // The list of suggestions for the attribute. + repeated string suggestions = 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 case. + // + // * They are UTF-8 safe. + // + // Recent searches are deduplicated. More recent searches will be reserved + // when duplication happens. + repeated RecentSearchResult recent_search_results = 3; + + // A map of matched attribute suggestions. This field is only available for + // "cloud-retail" dataset. + // + // Current supported keys: + // + // * `brands` + // + // * `categories` + map attribute_results = 4; +} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/control.proto b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/control.proto new file mode 100644 index 00000000000..5c3047ce438 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/control.proto @@ -0,0 +1,100 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; +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 metadata that can be linked to a +// [ServingConfig][google.cloud.retail.v2alpha.ServingConfig] and affect search +// or recommendation results at serving time. +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. + // + // Note that this field is deprecated and will throw NOT_IMPLEMENTED if + // used for creating a control. + SearchRequest.FacetSpec facet_spec = 3 [deprecated = true]; + + // 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 + // config][google.cloud.retail.v2alpha.ServingConfig] ids that are associated + // with this control in the same + // [Catalog][google.cloud.retail.v2alpha.Catalog]. + // + // Note the association is managed via the + // [ServingConfig][google.cloud.retail.v2alpha.ServingConfig], this is an + // output only denormalized view. + repeated string associated_serving_config_ids = 5 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Required. Immutable. The solution types that the control 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][google.cloud.retail.v2alpha.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated SolutionType solution_types = 6 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; + + // 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][google.cloud.retail.v2alpha.SearchSolutionUseCase.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; +} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/control_service.proto b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/control_service.proto new file mode 100644 index 00000000000..7cfd462db97 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/control_service.proto @@ -0,0 +1,185 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; +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 update 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 by their parent + // [Catalog][google.cloud.retail.v2alpha.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 get. 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/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/export_config.proto b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/export_config.proto new file mode 100644 index 00000000000..40ceb9cdb3b --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/export_config.proto @@ -0,0 +1,107 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; +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 is +// 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; + + // This field is never set. + ExportErrorsConfig errors_config = 2; + + // Output result indicating where the data were exported to. + OutputResult output_result = 3; +} + +// 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; + + // This field is never set. + ExportErrorsConfig errors_config = 2; + + // Output result indicating where the data were exported to. + OutputResult output_result = 3; +} + +// Output result that stores the information about where the exported data is +// stored. +message OutputResult { + // The BigQuery location where the result is stored. + repeated BigQueryOutputResult bigquery_result = 1; + + // The Google Cloud Storage location where the result is stored. + repeated GcsOutputResult gcs_result = 2; +} + +// A BigQuery output result. +message BigQueryOutputResult { + // The ID of a BigQuery Dataset. + string dataset_id = 1; + + // The ID of a BigQuery Table. + string table_id = 2; +} + +// A Gcs output result. +message GcsOutputResult { + // The uri of Gcs output + string output_uri = 1; +} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/import_config.proto b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/import_config.proto new file mode 100644 index 00000000000..77ab88be3ef --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/import_config.proto @@ -0,0 +1,408 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; +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. +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 in + // [ImportProductsRequest][google.cloud.retail.v2alpha.ImportProductsRequest]. + 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`: + // The schema is available here: + // https://support.google.com/analytics/answer/7029846. + // + // Supported values for autocomplete 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 are 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. + 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, all fields are updated. + 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; + + // Full Pub/Sub topic name for receiving notification. If this field is set, + // when the import is finished, a notification is sent to + // specified Pub/Sub topic. The message data is 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.v2alpha.ImportProductsRequest.parent]. + // Make sure that `service-@gcp-sa-retail.iam.gserviceaccount.com` has the + // `pubsub.topics.publish` IAM permission on the topic. + string notification_pubsub_topic = 7; + + // If true, this performs the FULL import even if it would delete a large + // proportion of the products in the default branch, which could potentially + // cause outages if you have live predict/search traffic. + // + // Only supported when + // [ImportProductsRequest.reconciliation_mode][google.cloud.retail.v2alpha.ImportProductsRequest.reconciliation_mode] + // is set to `FULL`. + bool skip_default_branch_protection = 8; +} + +// 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 is sent to + // specified Pub/Sub topic. The message data is 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 is +// 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 is sent to + // specified Pub/Sub topic. The message data is JSON string of a + // [Operation][google.longrunning.Operation]. + // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. + string notification_pubsub_topic = 6; + + // Metadata related to transform user events. + TransformedUserEventsMetadata transformed_user_events_metadata = 7; +} + +// Metadata related to transform user events operation. +message TransformedUserEventsMetadata { + // Count of entries in the source user events BigQuery table. + int64 source_events_count = 1; + + // Count of entries in the transformed user events BigQuery table, which could + // be different from the actually imported number of user events. + int64 transformed_events_count = 2; +} + +// 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/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/merchant_center_account_link.proto b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/merchant_center_account_link.proto new file mode 100644 index 00000000000..5d8df7c8ab3 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/merchant_center_account_link.proto @@ -0,0 +1,137 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; +option java_multiple_files = true; +option java_outer_classname = "MerchantCenterAccountLinkProto"; +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"; + +// 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 MerchantCenterAccountLink { + option (google.api.resource) = { + type: "retail.googleapis.com/MerchantCenterAccountLink" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/merchantCenterAccountLinks/{merchant_center_account_link}" + }; + + // Merchant Center Feed filter criterion. + message MerchantCenterFeedFilter { + // Merchant Center primary feed ID. + int64 primary_feed_id = 1; + + // Merchant Center primary feed name. The name is used for the display + // purposes only. + string primary_feed_name = 2; + } + + // The state of the link. + enum State { + // Default value. + STATE_UNSPECIFIED = 0; + + // Link is created and LRO is not complete. + PENDING = 1; + + // Link is active. + ACTIVE = 2; + + // Link creation failed. + FAILED = 3; + } + + // Output only. Immutable. Full resource name of the Merchant Center Account + // Link, such as + // `projects/*/locations/global/catalogs/default_catalog/merchantCenterAccountLinks/merchant_center_account_link`. + string name = 1 [ + (google.api.field_behavior) = IMMUTABLE, + (google.api.field_behavior) = OUTPUT_ONLY + ]; + + // Output only. Immutable. + // [MerchantCenterAccountLink][google.cloud.retail.v2alpha.MerchantCenterAccountLink] + // identifier, which is the final component of + // [name][google.cloud.retail.v2alpha.MerchantCenterAccountLink.name]. This + // field is auto generated and follows the convention: + // `BranchId_MerchantCenterAccountId`. + // `projects/*/locations/global/catalogs/default_catalog/merchantCenterAccountLinks/id_1`. + string id = 8 [ + (google.api.field_behavior) = IMMUTABLE, + (google.api.field_behavior) = OUTPUT_ONLY + ]; + + // 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 = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The branch id (e.g. 0/1/2) within the 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 = 3 [(google.api.field_behavior) = REQUIRED]; + + // The FeedLabel used to perform filtering. + // Note: this replaces + // [region_id](https://developers.google.com/shopping-content/reference/rest/v2.1/products#Product.FIELDS.feed_label). + // + // Example value: `US`. + // Example value: `FeedLabel1`. + string feed_label = 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; + + // Criteria for the Merchant Center feeds to be ingested via the link. + // All offers will be ingested if the list is empty. + // Otherwise the offers will be ingested from selected feeds. + repeated MerchantCenterFeedFilter feed_filters = 6; + + // Output only. Represents the state of the link. + State state = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. GCP project ID. + string project_id = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// Common metadata related to the progress of the operations. +message CreateMerchantCenterAccountLinkMetadata { + // 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; +} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/merchant_center_account_link_service.proto b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/merchant_center_account_link_service.proto new file mode 100644 index 00000000000..93704f004c8 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/merchant_center_account_link_service.proto @@ -0,0 +1,140 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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/merchant_center_account_link.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/empty.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; +option java_multiple_files = true; +option java_outer_classname = "MerchantCenterAccountLinkServiceProto"; +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"; + +// Merchant Center Link service to link a Branch to a Merchant Center Account. +service MerchantCenterAccountLinkService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Lists all + // [MerchantCenterAccountLink][google.cloud.retail.v2alpha.MerchantCenterAccountLink]s + // under the specified parent [Catalog][google.cloud.retail.v2alpha.Catalog]. + rpc ListMerchantCenterAccountLinks(ListMerchantCenterAccountLinksRequest) + returns (ListMerchantCenterAccountLinksResponse) { + option (google.api.http) = { + get: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/merchantCenterAccountLinks" + }; + option (google.api.method_signature) = "parent"; + } + + // Creates a + // [MerchantCenterAccountLink][google.cloud.retail.v2alpha.MerchantCenterAccountLink]. + rpc CreateMerchantCenterAccountLink(CreateMerchantCenterAccountLinkRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/merchantCenterAccountLinks" + body: "merchant_center_account_link" + }; + option (google.api.method_signature) = + "parent,merchant_center_account_link"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2alpha.MerchantCenterAccountLink" + metadata_type: "google.cloud.retail.v2alpha.CreateMerchantCenterAccountLinkMetadata" + }; + } + + // Deletes a + // [MerchantCenterAccountLink][google.cloud.retail.v2alpha.MerchantCenterAccountLink]. + // If the + // [MerchantCenterAccountLink][google.cloud.retail.v2alpha.MerchantCenterAccountLink] + // to delete does not exist, a NOT_FOUND error is returned. + rpc DeleteMerchantCenterAccountLink(DeleteMerchantCenterAccountLinkRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v2alpha/{name=projects/*/locations/*/catalogs/*/merchantCenterAccountLinks/*}" + }; + option (google.api.method_signature) = "name"; + } +} + +// Request for +// [MerchantCenterAccountLinkService.ListMerchantCenterAccountLinks][google.cloud.retail.v2alpha.MerchantCenterAccountLinkService.ListMerchantCenterAccountLinks] +// method. +message ListMerchantCenterAccountLinksRequest { + // Required. The parent Catalog of the resource. + // It must match this format: + // projects/{PROJECT_NUMBER}/locations/global/catalogs/{CATALOG_ID} + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; +} + +// Response for +// [MerchantCenterAccountLinkService.ListMerchantCenterAccountLinks][google.cloud.retail.v2alpha.MerchantCenterAccountLinkService.ListMerchantCenterAccountLinks] +// method. +message ListMerchantCenterAccountLinksResponse { + // The links. + repeated MerchantCenterAccountLink merchant_center_account_links = 1; +} + +// Request for +// [MerchantCenterAccountLinkService.CreateMerchantCenterAccountLink][google.cloud.retail.v2alpha.MerchantCenterAccountLinkService.CreateMerchantCenterAccountLink] +// method. +message CreateMerchantCenterAccountLinkRequest { + // Required. The branch resource where this MerchantCenterAccountLink will be + // created. Format: + // projects/{PROJECT_NUMBER}/locations/global/catalogs/{CATALOG_ID}} + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } + ]; + + // Required. The + // [MerchantCenterAccountLink][google.cloud.retail.v2alpha.MerchantCenterAccountLink] + // to create. + // + // If the caller does not have permission to create the + // [MerchantCenterAccountLink][google.cloud.retail.v2alpha.MerchantCenterAccountLink], + // regardless of whether or not it exists, a PERMISSION_DENIED error is + // returned. + MerchantCenterAccountLink merchant_center_account_link = 2 + [(google.api.field_behavior) = REQUIRED]; +} + +// Request for +// [MerchantCenterAccountLinkService.DeleteMerchantCenterAccountLink][google.cloud.retail.v2alpha.MerchantCenterAccountLinkService.DeleteMerchantCenterAccountLink] +// method. +message DeleteMerchantCenterAccountLinkRequest { + // Required. Full resource name. Format: + // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/merchantCenterAccountLinks/{merchant_center_account_link_id} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "retail.googleapis.com/MerchantCenterAccountLink" + } + ]; +} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/model.proto b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/model.proto new file mode 100644 index 00000000000..b8f8cd8dcf8 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/model.proto @@ -0,0 +1,451 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; +option java_multiple_files = true; +option java_outer_classname = "ModelProto"; +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 that describes the training and serving parameters of a +// [Model][google.cloud.retail.v2alpha.Model]. A +// [Model][google.cloud.retail.v2alpha.Model] can be associated with a +// [ServingConfig][google.cloud.retail.v2alpha.ServingConfig] and then queried +// through the Predict API. +message Model { + option (google.api.resource) = { + type: "retail.googleapis.com/Model" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}" + }; + + // The PageOptimizationConfig for model training. + // + // This determines how many panels to optimize for, and which serving + // configs to consider for each panel. + // The purpose of this model is to optimize which + // [ServingConfig][google.cloud.retail.v2alpha.ServingConfig] to show on which + // panels in way that optimizes the visitors shopping journey. + message PageOptimizationConfig { + // A candidate to consider for a given panel. Currently only + // [ServingConfig][google.cloud.retail.v2alpha.ServingConfig] are valid + // candidates. + message Candidate { + oneof candidate { + // This has to be a valid + // [ServingConfig][google.cloud.retail.v2alpha.ServingConfig] + // identifier. For example, for a ServingConfig with full name: + // `projects/*/locations/global/catalogs/default_catalog/servingConfigs/my_candidate_config`, + // this would be `my_candidate_config`. + string serving_config_id = 1; + } + } + + // An individual panel with a list of + // [ServingConfigs][google.cloud.retail.v2alpha.ServingConfig] to consider + // for it. + message Panel { + // Optional. The name to display for the panel. + string display_name = 1 [(google.api.field_behavior) = OPTIONAL]; + + // Required. The candidates to consider on the panel. + repeated Candidate candidates = 2 + [(google.api.field_behavior) = REQUIRED]; + + // Required. The default candidate. If the model fails at serving time, + // we fall back to the default. + Candidate default_candidate = 3 [(google.api.field_behavior) = REQUIRED]; + } + + // Restrictions of expected returned results. + enum Restriction { + // Unspecified value for restriction. + RESTRICTION_UNSPECIFIED = 0; + + // Allow any [ServingConfig][google.cloud.retail.v2alpha.ServingConfig] to + // be show on any number of panels. + // + // Example: + // + // `Panel1 candidates`: pdp_ctr, pdp_cvr, home_page_ctr_no_diversity + // + // `Panel2 candidates`: home_page_ctr_no_diversity, + // home_page_ctr_diversity, + // pdp_cvr_no_diversity + // + // `Restriction` = NO_RESTRICTION + // + // `Valid combinations`: + // + // * (pdp_ctr, home_page_ctr_no_diversity) + // * (pdp_ctr, home_page_ctr_diversity) + // * (pdp_ctr, pdp_cvr_no_diversity) + // * (pdp_cvr, home_page_ctr_no_diversity) + // * (pdp_cvr, home_page_ctr_diversity) + // * (pdp_cvr, pdp_cvr_no_diversity) + // * (home_page_ctr_no_diversity, home_page_ctr_no_diversity) + // * (home_page_ctr_no_diversity, home_page_ctr_diversity) + // * (home_page_ctr_no_diversity, pdp_cvr_no_diversity) + // + // `Invalid combinations`: [] + NO_RESTRICTION = 1; + + // Do not allow the same + // [ServingConfig.name][google.cloud.retail.v2alpha.ServingConfig.name] to + // be shown on multiple panels. + // + // Example: + // + // `Panel1 candidates`: pdp_ctr, pdp_cvr, home_page_ctr_no_diversity + // + // + // `Panel2 candidates`: home_page_ctr_no_diversity, + // home_page_ctr_diversity_low, + // pdp_cvr_no_diversity + // + // `Restriction` = `UNIQUE_SERVING_CONFIG_RESTRICTION` + // + // `Valid combinations`: + // + // * (pdp_ctr, home_page_ctr_no_diversity) + // * (pdp_ctr, home_page_ctr_diversity_low) + // * (pdp_ctr, pdp_cvr_no_diversity) + // * (pdp_ctr, pdp_cvr_no_diversity) + // * (pdp_cvr, home_page_ctr_no_diversity) + // * (pdp_cvr, home_page_ctr_diversity_low) + // * (pdp_cvr, pdp_cvr_no_diversity) + // * (home_page_ctr_no_diversity, home_page_ctr_diversity_low) + // * (home_page_ctr_no_diversity, pdp_cvr_no_diversity) + // + // `Invalid combinations`: + // + // * (home_page_ctr_no_diversity, home_page_ctr_no_diversity) + UNIQUE_SERVING_CONFIG_RESTRICTION = 2; + + // Do not allow multiple + // [ServingConfigs][google.cloud.retail.v2alpha.ServingConfig] with same + // [Model.name][google.cloud.retail.v2alpha.Model.name] to be show on on + // different panels. + // + // Example: + // + // `Panel1 candidates`: pdp_ctr, pdp_cvr, home_page_ctr_no_diversity + // + // + // `Panel2 candidates`: home_page_ctr_no_diversity, + // home_page_ctr_diversity_low, + // pdp_cvr_no_diversity + // + // `Restriction` = `UNIQUE_MODEL_RESTRICTION` + // + // `Valid combinations`: + // + // * (pdp_ctr, home_page_ctr_no_diversity) + // * (pdp_ctr, home_page_ctr_diversity) + // * (pdp_ctr, pdp_cvr_no_diversity) + // * (pdp_ctr, pdp_cvr_no_diversity) + // * (pdp_cvr, home_page_ctr_no_diversity) + // * (pdp_cvr, home_page_ctr_diversity_low) + // * (home_page_ctr_no_diversity, pdp_cvr_no_diversity) + // + // `Invalid combinations`: + // + // * (home_page_ctr_no_diversity, home_page_ctr_no_diversity) + // * (pdp_cvr, pdp_cvr_no_diversity) + UNIQUE_MODEL_RESTRICTION = 3; + + // Do not allow multiple + // [ServingConfigs][google.cloud.retail.v2alpha.ServingConfig] with same + // [Model.type][google.cloud.retail.v2alpha.Model.type] to be shown on + // different panels. + // + // Example: + // + // `Panel1 candidates`: pdp_ctr, pdp_cvr, home_page_ctr_no_diversity + // + // + // `Panel2 candidates`: home_page_ctr_no_diversity, + // home_page_ctr_diversity_low, + // pdp_cvr_no_diversity + // + // `Restriction` = `UNIQUE_MODEL_RESTRICTION` + // + // `Valid combinations`: + // + // * (pdp_ctr, home_page_ctr_no_diversity) + // * (pdp_ctr, home_page_ctr_diversity) + // * (pdp_cvr, home_page_ctr_no_diversity) + // * (pdp_cvr, home_page_ctr_diversity_low) + // * (home_page_ctr_no_diversity, pdp_cvr_no_diversity) + // + // `Invalid combinations`: + // + // * (pdp_ctr, pdp_cvr_no_diversity) + // * (pdp_ctr, pdp_cvr_no_diversity) + // * (pdp_cvr, pdp_cvr_no_diversity) + // * (home_page_ctr_no_diversity, home_page_ctr_no_diversity) + // * (home_page_ctr_no_diversity, home_page_ctr_diversity) + UNIQUE_MODEL_TYPE_RESTRICTION = 4; + } + + // Required. The type of [UserEvent][google.cloud.retail.v2alpha.UserEvent] + // this page optimization is shown for. + // + // Each page has an associated event type - this will be the + // corresponding event type for the page that the page optimization + // model is used on. + // + // Supported types: + // + // * `add-to-cart`: Products being added to cart. + // * `detail-page-view`: Products detail page viewed. + // * `home-page-view`: Homepage viewed + // * `category-page-view`: Homepage viewed + // * `shopping-cart-page-view`: User viewing a shopping cart. + // + // `home-page-view` only allows models with type `recommended-for-you`. + // All other page_optimization_event_type allow all + // [Model.types][google.cloud.retail.v2alpha.Model.type]. + string page_optimization_event_type = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Required. A list of panel configurations. + // + // Limit = 5. + repeated Panel panels = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. How to restrict results across panels e.g. can the same + // [ServingConfig][google.cloud.retail.v2alpha.ServingConfig] be shown on + // multiple panels at once. + // + // If unspecified, default to `UNIQUE_MODEL_RESTRICTION`. + Restriction restriction = 3 [(google.api.field_behavior) = OPTIONAL]; + } + + // Represents an ordered combination of valid serving configs, which + // can be used for `PAGE_OPTIMIZATION` recommendations. + message ServingConfigList { + // Optional. A set of valid serving configs that may be used for + // `PAGE_OPTIMIZATION`. + repeated string serving_config_ids = 1 + [(google.api.field_behavior) = OPTIONAL]; + } + + // The serving state of the model. + enum ServingState { + // Unspecified serving state. + SERVING_STATE_UNSPECIFIED = 0; + + // The model is not serving. + INACTIVE = 1; + + // The model is serving and can be queried. + ACTIVE = 2; + + // The model is trained on tuned hyperparameters and can be + // queried. + TUNED = 3; + } + + // The training state of the model. + enum TrainingState { + // Unspecified training state. + TRAINING_STATE_UNSPECIFIED = 0; + + // The model training is paused. + PAUSED = 1; + + // The model is training. + TRAINING = 2; + } + + // Describes whether periodic tuning is enabled for this model + // or not. Periodic tuning is scheduled at most every three months. You can + // start a tuning process manually by using the `TuneModel` + // method, which starts a tuning process immediately and resets the quarterly + // schedule. Enabling or disabling periodic tuning does not affect any + // current tuning processes. + enum PeriodicTuningState { + // Unspecified default value, should never be explicitly set. + PERIODIC_TUNING_STATE_UNSPECIFIED = 0; + + // The model has periodic tuning disabled. Tuning + // can be reenabled by calling the `EnableModelPeriodicTuning` + // method or by calling the `TuneModel` method. + PERIODIC_TUNING_DISABLED = 1; + + // The model cannot be tuned with periodic tuning OR the + // `TuneModel` method. Hide the options in customer UI and + // reject any requests through the backend self serve API. + ALL_TUNING_DISABLED = 3; + + // The model has periodic tuning enabled. Tuning + // can be disabled by calling the `DisableModelPeriodicTuning` + // method. + PERIODIC_TUNING_ENABLED = 2; + } + + // Describes whether this model have sufficient training data + // to be continuously trained. + enum DataState { + // Unspecified default value, should never be explicitly set. + DATA_STATE_UNSPECIFIED = 0; + + // The model has sufficient training data. + DATA_OK = 1; + + // The model does not have sufficient training data. Error + // messages can be queried via Stackdriver. + DATA_ERROR = 2; + } + + // Training configuration specific to a + // [Model.type][google.cloud.retail.v2alpha.Model.type] - currently, only for + // page optimization. + oneof training_config { + // Optional. The page optimization config. + PageOptimizationConfig page_optimization_config = 17 + [(google.api.field_behavior) = OPTIONAL]; + } + + // Required. The fully qualified resource name of the model. + // + // Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + // catalog_id has char limit of 50. + // recommendation_model_id has char limit of 40. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The display name of the model. + // + // Should be human readable, used to display Recommendation Models in the + // Retail Cloud Console Dashboard. UTF-8 encoded string with limit of 1024 + // characters. + string display_name = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. The training state that the model is in (e.g. + // `TRAINING` or `PAUSED`). + // + // Since part of the cost of running the service + // is frequency of training - this can be used to determine when to train + // model in order to control cost. If not specified: the default value for + // `CreateModel` method is `TRAINING`. The default value for + // `UpdateModel` method is to keep the state the same as before. + TrainingState training_state = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. The serving state of the model: `ACTIVE`, `NOT_ACTIVE`. + ServingState serving_state = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Timestamp the Recommendation Model was created at. + google.protobuf.Timestamp create_time = 5 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Timestamp the Recommendation Model was last updated. E.g. + // if a Recommendation Model was paused - this would be the time the pause was + // initiated. + google.protobuf.Timestamp update_time = 6 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Required. The type of model e.g. `home-page`. + // + // Currently supported values: `recommended-for-you`, `others-you-may-like`, + // `frequently-bought-together`, `page-optimization`, `similar-items`, + // `buy-it-again`, `on-sale-items`, and `recently-viewed`(readonly value). + // + // + // This field together with + // [optimization_objective][google.cloud.retail.v2alpha.Model.optimization_objective] + // describe model metadata to use to control model training and serving. + // See https://cloud.google.com/retail/docs/models + // for more details on what the model metadata control and which combination + // of parameters are valid. For invalid combinations of parameters (e.g. type + // = `frequently-bought-together` and optimization_objective = `ctr`), you + // receive an error 400 if you try to create/update a recommendation with + // this set of knobs. + string type = 7 [(google.api.field_behavior) = REQUIRED]; + + // Optional. The optimization objective e.g. `cvr`. + // + // Currently supported + // values: `ctr`, `cvr`, `revenue-per-order`. + // + // If not specified, we choose default based on model type. + // Default depends on type of recommendation: + // + // `recommended-for-you` => `ctr` + // + // `others-you-may-like` => `ctr` + // + // `frequently-bought-together` => `revenue_per_order` + // + // This field together with + // [optimization_objective][google.cloud.retail.v2alpha.Model.type] + // describe model metadata to use to control model training and serving. + // See https://cloud.google.com/retail/docs/models + // for more details on what the model metadata control and which combination + // of parameters are valid. For invalid combinations of parameters (e.g. type + // = `frequently-bought-together` and optimization_objective = `ctr`), you + // receive an error 400 if you try to create/update a recommendation with + // this set of knobs. + string optimization_objective = 8 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The state of periodic tuning. + // + // The period we use is 3 months - to do a + // one-off tune earlier use the `TuneModel` method. Default value + // is `PERIODIC_TUNING_ENABLED`. + PeriodicTuningState periodic_tuning_state = 11 + [(google.api.field_behavior) = OPTIONAL]; + + // Output only. The timestamp when the latest successful tune finished. + google.protobuf.Timestamp last_tune_time = 12 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The tune operation associated with the model. + // + // Can be used to determine if there is an ongoing tune for this + // recommendation. Empty field implies no tune is goig on. + string tuning_operation = 15 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The state of data requirements for this model: `DATA_OK` and + // `DATA_ERROR`. + // + // Recommendation model cannot be trained if the data is in + // `DATA_ERROR` state. Recommendation model can have `DATA_ERROR` state even + // if serving state is `ACTIVE`: models were trained successfully before, but + // cannot be refreshed because model no longer has sufficient + // data for training. + DataState data_state = 16 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. If `RECOMMENDATIONS_FILTERING_ENABLED`, recommendation filtering + // by attributes is enabled for the model. + RecommendationsFilteringOption filtering_option = 18 + [(google.api.field_behavior) = OPTIONAL]; + + // Output only. The list of valid serving configs associated with the + // PageOptimizationConfig. + repeated ServingConfigList serving_config_lists = 19 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/model_service.proto b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/model_service.proto new file mode 100644 index 00000000000..e26fc8b4205 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/model_service.proto @@ -0,0 +1,263 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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/model.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; +option java_multiple_files = true; +option java_outer_classname = "ModelServiceProto"; +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 performing CRUD operations on models. +// Recommendation models contain all the metadata necessary to generate a set of +// models for the `Predict()` API. A model is queried +// indirectly via a ServingConfig, which associates a model with a +// given Placement (e.g. Frequently Bought Together on Home Page). +// +// This service allows you to do the following: +// +// * Initiate training of a model. +// * Pause training of an existing model. +// * List all the available models along with their metadata. +// * Control their tuning schedule. +service ModelService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Creates a new model. + rpc CreateModel(CreateModelRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/models" + body: "model" + }; + option (google.api.method_signature) = "parent,model"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2alpha.Model" + metadata_type: "google.cloud.retail.v2alpha.CreateModelMetadata" + }; + } + + // Gets a model. + rpc GetModel(GetModelRequest) returns (Model) { + option (google.api.http) = { + get: "/v2alpha/{name=projects/*/locations/*/catalogs/*/models/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Pauses the training of an existing model. + rpc PauseModel(PauseModelRequest) returns (Model) { + option (google.api.http) = { + post: "/v2alpha/{name=projects/*/locations/*/catalogs/*/models/*}:pause" + body: "*" + }; + option (google.api.method_signature) = "name"; + } + + // Resumes the training of an existing model. + rpc ResumeModel(ResumeModelRequest) returns (Model) { + option (google.api.http) = { + post: "/v2alpha/{name=projects/*/locations/*/catalogs/*/models/*}:resume" + body: "*" + }; + option (google.api.method_signature) = "name"; + } + + // Deletes an existing model. + rpc DeleteModel(DeleteModelRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v2alpha/{name=projects/*/locations/*/catalogs/*/models/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists all the models linked to this event store. + rpc ListModels(ListModelsRequest) returns (ListModelsResponse) { + option (google.api.http) = { + get: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/models" + }; + option (google.api.method_signature) = "parent"; + } + + // Update of model metadata. Only fields that + // currently can be updated are: `filtering_option` and + // `periodic_tuning_state`. + // If other values are provided, this API method ignores them. + rpc UpdateModel(UpdateModelRequest) returns (Model) { + option (google.api.http) = { + patch: "/v2alpha/{model.name=projects/*/locations/*/catalogs/*/models/*}" + body: "model" + }; + option (google.api.method_signature) = "model,update_mask"; + } + + // Tunes an existing model. + rpc TuneModel(TuneModelRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2alpha/{name=projects/*/locations/*/catalogs/*/models/*}:tune" + body: "*" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2alpha.TuneModelResponse" + metadata_type: "google.cloud.retail.v2alpha.TuneModelMetadata" + }; + } +} + +// Request for creating a model. +message CreateModelRequest { + // Required. The parent resource under which to create the model. 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 payload of the [Model][google.cloud.retail.v2alpha.Model] to + // create. + Model model = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Whether to run a dry run to validate the request (without + // actually creating the model). + bool dry_run = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Request for updating an existing model. +message UpdateModelRequest { + // Required. The body of the updated + // [Model][google.cloud.retail.v2alpha.Model]. + Model model = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Indicates which fields in the provided 'model' to + // update. If not set, by default updates all fields. + google.protobuf.FieldMask update_mask = 2 + [(google.api.field_behavior) = OPTIONAL]; +} + +// Request for getting a model. +message GetModelRequest { + // Required. The resource name of the + // [Model][google.cloud.retail.v2alpha.Model] to get. Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog}/models/{model_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Model" } + ]; +} + +// Request for pausing training of a model. +message PauseModelRequest { + // Required. The name of the model to pause. + // Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Model" } + ]; +} + +// Request for resuming training of a model. +message ResumeModelRequest { + // Required. The name of the model to resume. + // Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for listing models associated with a resource. +message ListModelsRequest { + // Required. The parent for which to list models. + // 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 `ListModels` + // call. Provide this to retrieve the subsequent page. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Request for deleting a model. +message DeleteModelRequest { + // Required. The resource name of the + // [Model][google.cloud.retail.v2alpha.Model] to delete. Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Model" } + ]; +} + +// Response to a ListModelRequest. +message ListModelsResponse { + // List of Models. + repeated Model models = 1; + + // Pagination token, if not returned indicates the last page. + string next_page_token = 2; +} + +// Request to manually start a tuning process now (instead of waiting for +// the periodically scheduled tuning to happen). +message TuneModelRequest { + // Required. The resource name of the model to tune. + // Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Model" } + ]; +} + +// Metadata associated with a create operation. +message CreateModelMetadata { + // The resource name of the model that this create applies to. + // Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + string model = 1; +} + +// Metadata associated with a tune operation. +message TuneModelMetadata { + // The resource name of the model that this tune applies to. + // Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + string model = 1; +} + +// Response associated with a tune operation. +message TuneModelResponse {} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/prediction_service.proto b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/prediction_service.proto new file mode 100644 index 00000000000..30fb4bf464d --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/prediction_service.proto @@ -0,0 +1,226 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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/user_event.proto"; +import "google/protobuf/struct.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; +option go_package = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; +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: "*" + additional_bindings { + post: "/v2alpha/{placement=projects/*/locations/*/catalogs/*/servingConfigs/*}:predict" + body: "*" + } + }; + } +} + +// Request message for Predict method. +message PredictRequest { + // Required. Full resource name of the format: + // `{placement=projects/*/locations/global/catalogs/default_catalog/servingConfigs/*}` + // or + // `{placement=projects/*/locations/global/catalogs/default_catalog/placements/*}`. + // We recommend using the `servingConfigs` resource. `placements` is a legacy + // resource. + // The ID of the Recommendations AI serving config or placement. + // Before you can request predictions from your model, you must create at + // least one serving config or placement for it. For more information, see + // [Manage serving configs] + // (https://cloud.google.com/retail/docs/manage-configs). + // + // The full list of available serving configs can be seen at + // https://console.cloud.google.com/ai/retail/catalogs/default_catalog/configs + 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.v2alpha.UserEvent.visitor_id] or + // [UserInfo.user_id][google.cloud.retail.v2alpha.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.v2alpha.UserEvent.visitor_id] to + // a random unique ID and leave + // [UserInfo.user_id][google.cloud.retail.v2alpha.UserInfo.user_id] unset. + UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED]; + + // Maximum number of results to return. 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; + + // This field is not used; leave it unset. + string page_token = 4 [deprecated = true]; + + // 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 *no* + // results. If instead you want empty result sets to return generic + // (unfiltered) popular products, set `strictFiltering` to False in + // `PredictRequest.params`. Note that the API will never return items with + // storageStatus of "EXPIRED" or "DELETED" regardless of filter choices. + // + // If `filterSyntaxV2` is set to true under the `params` field, then + // attribute-based expressions are expected instead of the above described + // tag-based syntax. Examples: + // + // * (colors: ANY("Red", "Blue")) AND NOT (categories: ANY("Phones")) + // * (availability: ANY("IN_STOCK")) AND + // (colors: ANY("Red") OR categories: ANY("Phones")) + // + // For more information, see + // [Filter recommendations](https://cloud.google.com/retail/docs/filter-recs). + 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 a 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. + // * `filterSyntaxV2`: Boolean. False by default. If set to true, the `filter` + // field is interpreteted according to the new, attribute-based syntax. + 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.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/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/product.proto b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/product.proto new file mode 100644 index 00000000000..3dc548fde24 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/product.proto @@ -0,0 +1,598 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; +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]. + // Note that this is only applicable to + // [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] and + // [Type.COLLECTION][google.cloud.retail.v2alpha.Product.Type.COLLECTION], + // and ignored for + // [Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT]. In + // general, we suggest the users to delete the stale products explicitly, + // instead of using this field to determine staleness. + // + // 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. Note that this is only + // applicable to + // [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] and + // [Type.COLLECTION][google.cloud.retail.v2alpha.Product.Type.COLLECTION], + // and ignored for + // [Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT]. In + // general, we suggest the users to delete the stale products explicitly, + // instead of using this field to determine staleness. + // + // 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 + // an 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, 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]. + // Note that this is only applicable to + // [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] and + // [Type.COLLECTION][google.cloud.retail.v2alpha.Product.Type.COLLECTION], and + // ignored for + // [Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT]. + 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] + // + // The maximum number of paths is 30. Otherwise, an INVALID_ARGUMENT error is + // returned. + // + // Note: Returning more fields in + // [SearchResponse][google.cloud.retail.v2alpha.SearchResponse] can increase + // response payload size and serving latency. + // + // This field is deprecated. Use the retrievable site-wide control instead. + google.protobuf.FieldMask retrievable_fields = 30 [deprecated = true]; + + // 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]; + + // Output only. A list of local inventories specific to different places. + // + // This field can be managed by + // [ProductService.AddLocalInventories][google.cloud.retail.v2alpha.ProductService.AddLocalInventories] + // and + // [ProductService.RemoveLocalInventories][google.cloud.retail.v2alpha.ProductService.RemoveLocalInventories] + // APIs if fine-grained, high-volume updates are necessary. + repeated LocalInventory local_inventories = 35 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/product_service.proto b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/product_service.proto new file mode 100644 index 00000000000..c954d8c6114 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/product_service.proto @@ -0,0 +1,988 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; +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 + // [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] + // or + // [ProductService.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. + // 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 is 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 + // [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] + // or + // [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. + // + // When inventory is updated with + // [ProductService.CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] + // and + // [ProductService.UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct], + // the specified inventory field value(s) overwrite any existing value(s) + // while ignoring the last update time for this field. Furthermore, the last + // update times for the specified inventory fields are overwritten by the + // times of the + // [ProductService.CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] + // or + // [ProductService.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 is used. + // + // If no inventory fields are set in + // [SetInventoryRequest.set_mask][google.cloud.retail.v2alpha.SetInventoryRequest.set_mask], + // then any existing inventory information is preserved. + // + // Pre-existing inventory information can only be updated with + // [ProductService.SetInventory][google.cloud.retail.v2alpha.ProductService.SetInventory], + // [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlaces], + // and + // [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces]. + // + // The returned [Operation][google.longrunning.Operation]s is obsolete after + // one day, and the [GetOperation][google.longrunning.Operations.GetOperation] + // API returns `NOT_FOUND` afterwards. + // + // If conflicting updates are issued, the + // [Operation][google.longrunning.Operation]s associated with the stale + // updates are not marked as [done][google.longrunning.Operation.done] until + // they are obsolete. + 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" + }; + } + + // It is recommended to use the + // [ProductService.AddLocalInventories][google.cloud.retail.v2alpha.ProductService.AddLocalInventories] + // method instead of + // [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlaces]. + // [ProductService.AddLocalInventories][google.cloud.retail.v2alpha.ProductService.AddLocalInventories] + // achieves the same results but provides more fine-grained control over + // ingesting local inventory data. + // + // 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 + // [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] + // or + // [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. + // + // The returned [Operation][google.longrunning.Operation]s will be obsolete + // after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] + // API will return NOT_FOUND afterwards. + // + // If conflicting updates are issued, the + // [Operation][google.longrunning.Operation]s associated with the stale + // updates will not be marked as [done][google.longrunning.Operation.done] + // until being obsolete. + 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" + }; + } + + // It is recommended to use the + // [ProductService.RemoveLocalInventories][google.cloud.retail.v2alpha.ProductService.RemoveLocalInventories] + // method instead of + // [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces]. + // [ProductService.RemoveLocalInventories][google.cloud.retail.v2alpha.ProductService.RemoveLocalInventories] + // achieves the same results but provides more fine-grained control over + // ingesting local inventory data. + // + // 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 + // [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] + // or + // [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. + // + // The returned [Operation][google.longrunning.Operation]s will be obsolete + // after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] + // API will return NOT_FOUND afterwards. + // + // If conflicting updates are issued, the + // [Operation][google.longrunning.Operation]s associated with the stale + // updates will not be marked as [done][google.longrunning.Operation.done] + // until being obsolete. + 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 + // [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] + // or + // [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. + // + // Local inventory information can only be modified using this method. + // [ProductService.CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] + // and + // [ProductService.UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct] + // has no effect on local inventories. + // + // The returned [Operation][google.longrunning.Operation]s will be obsolete + // after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] + // API will return NOT_FOUND afterwards. + // + // If conflicting updates are issued, the + // [Operation][google.longrunning.Operation]s associated with the stale + // updates will not be marked as [done][google.longrunning.Operation.done] + // until being obsolete. + 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 + // [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] + // or + // [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. + // + // Local inventory information can only be removed using this method. + // [ProductService.CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] + // and + // [ProductService.UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct] + // has no effect on local inventories. + // + // The returned [Operation][google.longrunning.Operation]s will be obsolete + // after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] + // API will return NOT_FOUND afterwards. + // + // If conflicting updates are issued, the + // [Operation][google.longrunning.Operation]s associated with the stale + // updates will not be marked as [done][google.longrunning.Operation.done] + // until being obsolete. + 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 +// [ProductService.CreateProduct][google.cloud.retail.v2alpha.ProductService.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 +// [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.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 +// [ProductService.UpdateProduct][google.cloud.retail.v2alpha.ProductService.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. + // + // 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.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 +// [ProductService.DeleteProduct][google.cloud.retail.v2alpha.ProductService.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" } + ]; + + // This value only applies to the case when the target product is of type + // PRIMARY. + // When deleting a product of VARIANT/COLLECTION type, this value + // will be ignored. + // When set to true, the subsequent variant products will be + // deleted. + // When set to false, if the primary product has active variant products, an + // error will be returned. + bool force = 4; +} + +// 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 +// [ProductService.SetInventory][google.cloud.retail.v2alpha.ProductService.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][google.cloud.retail.v2alpha.Product.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][google.cloud.retail.v2alpha.Product.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][google.cloud.retail.v2alpha.Product.fulfillment_info] + // * Checks that only the desired fulfillment info types have empty + // [SetInventoryRequest.inventory.fulfillment_info.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.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, + // [ProductService.UpdateProduct][google.cloud.retail.v2alpha.ProductService.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 +// [ProductService.SetInventory][google.cloud.retail.v2alpha.ProductService.SetInventory] +// method. +message SetInventoryMetadata {} + +// Response of the SetInventoryRequest. Currently empty because +// there is no meaningful response populated from the +// [ProductService.SetInventory][google.cloud.retail.v2alpha.ProductService.SetInventory] +// method. +message SetInventoryResponse {} + +// Request message for +// [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.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][google.cloud.retail.v2alpha.FulfillmentInfo.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 +// [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2alpha.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.v2alpha.ProductService.AddFulfillmentPlaces] +// method. +message AddFulfillmentPlacesResponse {} + +// Request message for +// [ProductService.AddLocalInventories][google.cloud.retail.v2alpha.ProductService.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 +// [ProductService.AddLocalInventories][google.cloud.retail.v2alpha.ProductService.AddLocalInventories] +// method. +message AddLocalInventoriesMetadata {} + +// Response of the +// [ProductService.AddLocalInventories][google.cloud.retail.v2alpha.ProductService.AddLocalInventories] +// API. Currently empty because there is no meaningful response populated from +// the +// [ProductService.AddLocalInventories][google.cloud.retail.v2alpha.ProductService.AddLocalInventories] +// method. +message AddLocalInventoriesResponse {} + +// Request message for +// [ProductService.RemoveLocalInventories][google.cloud.retail.v2alpha.ProductService.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 +// [ProductService.RemoveLocalInventories][google.cloud.retail.v2alpha.ProductService.RemoveLocalInventories] +// method. +message RemoveLocalInventoriesMetadata {} + +// Response of the +// [ProductService.RemoveLocalInventories][google.cloud.retail.v2alpha.ProductService.RemoveLocalInventories] +// API. Currently empty because there is no meaningful response populated from +// the +// [ProductService.RemoveLocalInventories][google.cloud.retail.v2alpha.ProductService.RemoveLocalInventories] +// method. +message RemoveLocalInventoriesResponse {} + +// Request message for +// [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.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][google.cloud.retail.v2alpha.FulfillmentInfo.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 +// [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces] +// method. +message RemoveFulfillmentPlacesMetadata {} + +// Response of the RemoveFulfillmentPlacesRequest. Currently empty because there +// is no meaningful response populated from the +// [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces] +// method. +message RemoveFulfillmentPlacesResponse {} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/promotion.proto b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/promotion.proto new file mode 100644 index 00000000000..63a80737cc7 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/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 = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; +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/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/purge_config.proto b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/purge_config.proto new file mode 100644 index 00000000000..b7b9ab81441 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/purge_config.proto @@ -0,0 +1,174 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; +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, + (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.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/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/search_service.proto b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/search_service.proto new file mode 100644 index 00000000000..f2931e40ed6 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/search_service.proto @@ -0,0 +1,1032 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; +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"; +option (google.api.resource_definition) = { + type: "retail.googleapis.com/Experiment" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/experiments/{experiment}" +}; + +// Service for search. +// +// This feature is only available for users who have Retail Search enabled. +// 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. + // 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: "*" + additional_bindings { + post: "/v2alpha/{placement=projects/*/locations/*/catalogs/*/servingConfigs/*}: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 40. + // + // For all numerical facet keys that appear in the list of products from + // the catalog, the percentiles 0, 10, 30, 50, 70, 90 and 100 are + // computed from their distribution weekly. If the model assigns a high + // score to a numerical facet key and its intervals are not specified in + // the search request, these percentiles will become the bounds + // for its intervals and will be returned in the response. If the + // facet key intervals are specified in the request, then the specified + // intervals will be returned instead. + 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; + + // True to make facet keys case insensitive when getting faceting + // values with prefixes or contains; false otherwise. + bool case_insensitive = 10; + + // The order in which + // [SearchResponse.Facet.values][google.cloud.retail.v2alpha.SearchResponse.Facet.values] + // are returned. + // + // Allowed values are: + // + // * "count desc", which means order by + // [SearchResponse.Facet.values.count][google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue.count] + // descending. + // + // * "value desc", which means order by + // [SearchResponse.Facet.values.value][google.cloud.retail.v2alpha.SearchResponse.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, + // [SearchResponse.Facet.values.value][google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue.value] + // will be always "1" and + // [SearchResponse.Facet.values.count][google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue.count] + // will be the number of results that match 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; + + // Returns the min and max value for each numerical facet intervals. + // Ignored for textual facets. + bool return_min_max = 11; + } + + // 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 50. 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. + // + // 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.v2alpha.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.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 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.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. In this case, server behavior + // 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. In this case, server behavior defaults to + // [Mode.AUTO][google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec.Mode.AUTO]. + MODE_UNSPECIFIED = 0; + + // Let CRS decide whether to use personalization based on quality of user + // event data. + AUTO = 1; + + // Disable personalization. + DISABLED = 2; + } + + // Defaults to + // [Mode.AUTO][google.cloud.retail.v2alpha.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. In this case, server behavior + // defaults to + // [Mode.AUTO][google.cloud.retail.v2alpha.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.v2alpha.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.v2alpha.SearchRequest.SpellCorrectionSpec.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. In this case, server behavior 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][google.cloud.retail.v2alpha.SearchResponse.SearchResult] + // and + // [SearchResponse.Facet][google.cloud.retail.v2alpha.SearchResponse.Facet] + // will be returned. + SEARCH_MODE_UNSPECIFIED = 0; + + // Only product search will be performed. The faceted search will be + // disabled. + // + // Only + // [SearchResponse.SearchResult][google.cloud.retail.v2alpha.SearchResponse.SearchResult] + // will be returned. + // [SearchResponse.Facet][google.cloud.retail.v2alpha.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_specs][google.cloud.retail.v2alpha.SearchRequest.facet_specs] + // 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][google.cloud.retail.v2alpha.SearchResponse.Facet] + // will be returned. + // [SearchResponse.SearchResult][google.cloud.retail.v2alpha.SearchResponse.SearchResult] + // will not be returned. + FACETED_SEARCH_ONLY = 2; + } + + // Required. The resource name of the Retail Search serving config, such as + // `projects/*/locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` + // or the name of the legacy placement resource, such as + // `projects/*/locations/global/catalogs/default_catalog/placements/default_search`. + // This field is used to identify the serving config 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.v2alpha.SearchRequest.filter] and + // [page_categories][google.cloud.retail.v2alpha.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.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 200 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][google.cloud.retail.v2alpha.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.local_inventories.attributes][google.cloud.retail.v2alpha.LocalInventory.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. Must be set 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, 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. + // + // Notice that if both + // [ServingConfig.personalization_spec][google.cloud.retail.v2alpha.ServingConfig.personalization_spec] + // and + // [SearchRequest.personalization_spec][google.cloud.retail.v2alpha.SearchRequest.personalization_spec] + // are set. + // [SearchRequest.personalization_spec][google.cloud.retail.v2alpha.SearchRequest.personalization_spec] + // will override + // [ServingConfig.personalization_spec][google.cloud.retail.v2alpha.ServingConfig.personalization_spec]. + 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; + + // The entity for customers that may run multiple different entities, domains, + // sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, + // `google.com`, `youtube.com`, etc. + // If this is set, it should be exactly matched with + // [UserEvent.entity][google.cloud.retail.v2alpha.UserEvent.entity] to get + // search results boosted by entity. + string entity = 38; +} + +// 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; + + // Specifies previous events related to this product for this user based on + // [UserEvent][google.cloud.retail.v2alpha.UserEvent] with same + // [SearchRequest.visitor_id][google.cloud.retail.v2alpha.SearchRequest.visitor_id] + // or [UserInfo.user_id][google.cloud.retail.v2alpha.UserInfo.user_id]. + // + // This is set only when + // [SearchRequest.PersonalizationSpec.mode][google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec.mode] + // is + // [SearchRequest.PersonalizationSpec.Mode.AUTO][google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec.Mode.AUTO]. + // + // Possible values: + // + // * `purchased`: Indicates that this product has been purchased before. + repeated string personal_labels = 7; + } + + // 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 minimum value in the + // [FacetValue.interval][google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue.interval]. + // Only supported on numerical facets and returned if + // [SearchRequest.FacetSpec.FacetKey.return_min_max][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.return_min_max] + // is true. + double min_value = 5; + + // The maximum value in the + // [FacetValue.interval][google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue.interval]. + // Only supported on numerical facets and returned if + // [SearchRequest.FacetSpec.FacetKey.return_min_max][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.return_min_max] + // is true. + double max_value = 6; + } + + // 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; + + // 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 is used for search. + 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 is performed, and only + // [redirect_uri][google.cloud.retail.v2alpha.SearchResponse.redirect_uri] and + // [attribution_token][google.cloud.retail.v2alpha.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.v2alpha.SearchRequest.BoostSpec.condition_boost_specs] + // that are not applied during serving. + repeated SearchRequest.BoostSpec.ConditionBoostSpec + invalid_condition_boost_specs = 14; + + // Metadata related to A/B testing + // [Experiment][google.cloud.retail.v2alpha.Experiment] associated with this + // response. Only exists when an experiment is triggered. + repeated ExperimentInfo experiment_info = 17; +} + +// Metadata for active A/B testing [Experiments][]. +message ExperimentInfo { + // Metadata for active serving config A/B tests. + message ServingConfigExperiment { + // The fully qualified resource name of the original + // [SearchRequest.placement][google.cloud.retail.v2alpha.SearchRequest.placement] + // in the search request prior to reassignment by experiment API. For + // example: `projects/*/locations/*/catalogs/*/servingConfigs/*`. + string original_serving_config = 1 [(google.api.resource_reference) = { + type: "retail.googleapis.com/ServingConfig" + }]; + + // The fully qualified resource name of the serving config + // [VariantArm.serving_config_id][] responsible for generating the search + // response. For example: + // `projects/*/locations/*/catalogs/*/servingConfigs/*`. + string experiment_serving_config = 2 [(google.api.resource_reference) = { + type: "retail.googleapis.com/ServingConfig" + }]; + } + + // Information associated with the specific experiment entity being recorded. + oneof experiment_metadata { + // A/B test between existing Cloud Retail Search + // [ServingConfig][google.cloud.retail.v2alpha.ServingConfig]s. + ServingConfigExperiment serving_config_experiment = 2; + } + + // The fully qualified resource name of the experiment that provides the + // serving config under test, should an active experiment exist. For example: + // `projects/*/locations/global/catalogs/default_catalog/experiments/experiment_id` + string experiment = 1 [(google.api.resource_reference) = { + type: "retail.googleapis.com/Experiment" + }]; +} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/serving_config.proto b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/serving_config.proto new file mode 100644 index 00000000000..d4c89cb0c17 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/serving_config.proto @@ -0,0 +1,281 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; +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). +message ServingConfig { + option (google.api.resource) = { + type: "retail.googleapis.com/ServingConfig" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}" + }; + + // What type of diversity - data or rule based. + enum DiversityType { + // Default value. + DIVERSITY_TYPE_UNSPECIFIED = 0; + + // Rule based diversity. + RULE_BASED_DIVERSITY = 2; + + // Data driven diversity. + DATA_DRIVEN_DIVERSITY = 3; + } + + // 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 in the same + // [Catalog][google.cloud.retail.v2alpha.Catalog] 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-reranking` + // * `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][google.cloud.retail.v2alpha.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; + + // What kind of diversity to use - data driven or rule based. If unset, the + // server behavior defaults to + // [RULE_BASED_DIVERSITY][google.cloud.retail.v2alpha.ServingConfig.DiversityType.RULE_BASED_DIVERSITY]. + DiversityType diversity_type = 20; + + // 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; + + // The specification for personalization spec. + // + // 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]. + // + // Notice that if both + // [ServingConfig.personalization_spec][google.cloud.retail.v2alpha.ServingConfig.personalization_spec] + // and + // [SearchRequest.personalization_spec][google.cloud.retail.v2alpha.SearchRequest.personalization_spec] + // are set. + // [SearchRequest.personalization_spec][google.cloud.retail.v2alpha.SearchRequest.personalization_spec] + // will override + // [ServingConfig.personalization_spec][google.cloud.retail.v2alpha.ServingConfig.personalization_spec]. + SearchRequest.PersonalizationSpec personalization_spec = 21; + + // 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/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/serving_config_service.proto b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/serving_config_service.proto new file mode 100644 index 00000000000..abe94af65af --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/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 = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; +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/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/user_event.proto b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/user_event.proto new file mode 100644 index 00000000000..8ace03d047d --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/user_event.proto @@ -0,0 +1,354 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; +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. + // + // 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.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 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.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, 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; + + // The entity for customers that may run multiple different entities, domains, + // sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, + // `google.com`, `youtube.com`, etc. + // It is recommended to set this field to get better per-entity search, + // completion and prediction results. + string entity = 23; +} + +// 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/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/user_event_service.proto b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/user_event_service.proto new file mode 100644 index 00000000000..2a825e65230 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/user_event_service.proto @@ -0,0 +1,210 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; +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 + // are not annotated with detailed product information for products that are + // missing from the catalog when the user event is ingested. These + // events are stored as unjoined events with limited usage on training and + // serving. You can use this method to start a join operation on specified + // events with the latest version of product catalog. You can also use this + // method 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]; + + // If set to true, the user event will be written asynchronously after + // validation, and the API will respond without waiting for the write. + // Therefore, silent failures can occur even if the API returns success. In + // case of silent failures, error messages can be found in Stackdriver logs. + bool write_async = 3; +} + +// Request message for CollectUserEvent method. +message CollectUserEventRequest { + // The rule that can convert the raw_json to a user event. It is needed + // only when the raw_json is set. + oneof conversion_rule { + // The prebuilt rule name that can convert a specific type of raw_json. + // For example: "ga4_bq" rule for the GA4 user event schema. + string prebuilt_rule = 6; + } + + // 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; + + // An arbitrary serialized JSON string that contains necessary information + // that can comprise a user event. When this field is specified, the + // user_event field will be ignored. Note: line-delimited JSON is not + // supported, a single JSON only. + string raw_json = 5; +} + +// 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.add_catalog_attribute.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.add_catalog_attribute.js new file mode 100644 index 00000000000..cd1f26ba0a0 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.add_catalog_attribute.js @@ -0,0 +1,68 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.batch_remove_catalog_attributes.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.batch_remove_catalog_attributes.js new file mode 100644 index 00000000000..909b1f16079 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.batch_remove_catalog_attributes.js @@ -0,0 +1,70 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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, attributeKeys) { + // [START retail_v2alpha_generated_CatalogService_BatchRemoveCatalogAttributes_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The attributes config resource shared by all catalog attributes + * being deleted. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` + */ + // const attributesConfig = 'abc123' + /** + * Required. The attribute name keys of the + * CatalogAttribute google.cloud.retail.v2alpha.CatalogAttribute s to + * delete. A maximum of 1000 catalog attributes can be deleted in a batch. + */ + // const attributeKeys = 'abc123' + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callBatchRemoveCatalogAttributes() { + // Construct request + const request = { + attributesConfig, + attributeKeys, + }; + + // Run request + const response = await retailClient.batchRemoveCatalogAttributes(request); + console.log(response); + } + + callBatchRemoveCatalogAttributes(); + // [END retail_v2alpha_generated_CatalogService_BatchRemoveCatalogAttributes_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.get_attributes_config.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.get_attributes_config.js new file mode 100644 index 00000000000..aac5dac8ddb --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.get_attributes_config.js @@ -0,0 +1,62 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.get_completion_config.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.get_completion_config.js new file mode 100644 index 00000000000..e875759bbea --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.get_completion_config.js @@ -0,0 +1,62 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.get_default_branch.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.get_default_branch.js new file mode 100644 index 00000000000..4c14d06856f --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.get_default_branch.js @@ -0,0 +1,61 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.list_catalogs.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.list_catalogs.js new file mode 100644 index 00000000000..e8b3d5f2d83 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.list_catalogs.js @@ -0,0 +1,86 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.remove_catalog_attribute.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.remove_catalog_attribute.js new file mode 100644 index 00000000000..faed21407fd --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.remove_catalog_attribute.js @@ -0,0 +1,68 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.replace_catalog_attribute.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.replace_catalog_attribute.js new file mode 100644 index 00000000000..ca486f3d716 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.replace_catalog_attribute.js @@ -0,0 +1,76 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.set_default_branch.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.set_default_branch.js new file mode 100644 index 00000000000..8be4d79d371 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.set_default_branch.js @@ -0,0 +1,84 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.update_attributes_config.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.update_attributes_config.js new file mode 100644 index 00000000000..13c58537108 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.update_attributes_config.js @@ -0,0 +1,70 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.update_catalog.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.update_catalog.js new file mode 100644 index 00000000000..29e30046130 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.update_catalog.js @@ -0,0 +1,73 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.update_completion_config.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.update_completion_config.js new file mode 100644 index 00000000000..def26a2dbf0 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.update_completion_config.js @@ -0,0 +1,78 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/completion_service.complete_query.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/completion_service.complete_query.js new file mode 100644 index 00000000000..9dbf368c009 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/completion_service.complete_query.js @@ -0,0 +1,137 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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' + /** + * Note that this field applies for `user-data` dataset only. For requests + * with `cloud-retail` dataset, setting this field has no effect. + * 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. We recommend that you + * leave this field empty. + * It can 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 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 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 + /** + * If true, attribute suggestions are enabled and provided in response. + * This field is only available for "cloud-retail" dataset. + */ + // const enableAttributeSuggestions = true + /** + * The entity for customers that may run multiple different entities, domains, + * sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, + * `google.com`, `youtube.com`, etc. + * If this is set, it should be exactly matched with + * UserEvent.entity google.cloud.retail.v2alpha.UserEvent.entity to get + * per-entity autocomplete results. + */ + // const entity = 'abc123' + + // 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/completion_service.import_completion_data.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/completion_service.import_completion_data.js new file mode 100644 index 00000000000..7ebf210565d --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/completion_service.import_completion_data.js @@ -0,0 +1,76 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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 is sent to + * specified Pub/Sub topic. The message data is 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/control_service.create_control.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/control_service.create_control.js new file mode 100644 index 00000000000..5d9cc8c6f3c --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/control_service.create_control.js @@ -0,0 +1,75 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/control_service.delete_control.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/control_service.delete_control.js new file mode 100644 index 00000000000..192850511a2 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/control_service.delete_control.js @@ -0,0 +1,62 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/control_service.get_control.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/control_service.get_control.js new file mode 100644 index 00000000000..9e07fb8ced4 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/control_service.get_control.js @@ -0,0 +1,62 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the Control to get. 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/control_service.list_controls.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/control_service.list_controls.js new file mode 100644 index 00000000000..778d71bcd40 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/control_service.list_controls.js @@ -0,0 +1,82 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/control_service.update_control.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/control_service.update_control.js new file mode 100644 index 00000000000..ddae99da36f --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/control_service.update_control.js @@ -0,0 +1,69 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/merchant_center_account_link_service.create_merchant_center_account_link.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/merchant_center_account_link_service.create_merchant_center_account_link.js new file mode 100644 index 00000000000..fb1ea60a850 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/merchant_center_account_link_service.create_merchant_center_account_link.js @@ -0,0 +1,75 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, merchantCenterAccountLink) { + // [START retail_v2alpha_generated_MerchantCenterAccountLinkService_CreateMerchantCenterAccountLink_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The branch resource where this MerchantCenterAccountLink will be + * created. Format: + * projects/{PROJECT_NUMBER}/locations/global/catalogs/{CATALOG_ID}} + */ + // const parent = 'abc123' + /** + * Required. The + * MerchantCenterAccountLink google.cloud.retail.v2alpha.MerchantCenterAccountLink + * to create. + * If the caller does not have permission to create the + * MerchantCenterAccountLink google.cloud.retail.v2alpha.MerchantCenterAccountLink, + * regardless of whether or not it exists, a PERMISSION_DENIED error is + * returned. + */ + // const merchantCenterAccountLink = {} + + // Imports the Retail library + const {MerchantCenterAccountLinkServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new MerchantCenterAccountLinkServiceClient(); + + async function callCreateMerchantCenterAccountLink() { + // Construct request + const request = { + parent, + merchantCenterAccountLink, + }; + + // Run request + const [operation] = await retailClient.createMerchantCenterAccountLink(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateMerchantCenterAccountLink(); + // [END retail_v2alpha_generated_MerchantCenterAccountLinkService_CreateMerchantCenterAccountLink_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/merchant_center_account_link_service.delete_merchant_center_account_link.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/merchant_center_account_link_service.delete_merchant_center_account_link.js new file mode 100644 index 00000000000..941b02e5328 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/merchant_center_account_link_service.delete_merchant_center_account_link.js @@ -0,0 +1,62 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by 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_MerchantCenterAccountLinkService_DeleteMerchantCenterAccountLink_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/merchantCenterAccountLinks/{merchant_center_account_link_id} + */ + // const name = 'abc123' + + // Imports the Retail library + const {MerchantCenterAccountLinkServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new MerchantCenterAccountLinkServiceClient(); + + async function callDeleteMerchantCenterAccountLink() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.deleteMerchantCenterAccountLink(request); + console.log(response); + } + + callDeleteMerchantCenterAccountLink(); + // [END retail_v2alpha_generated_MerchantCenterAccountLinkService_DeleteMerchantCenterAccountLink_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/merchant_center_account_link_service.list_merchant_center_account_links.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/merchant_center_account_link_service.list_merchant_center_account_links.js new file mode 100644 index 00000000000..55634ba9ff8 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/merchant_center_account_link_service.list_merchant_center_account_links.js @@ -0,0 +1,63 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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_MerchantCenterAccountLinkService_ListMerchantCenterAccountLinks_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent Catalog of the resource. + * It must match this format: + * projects/{PROJECT_NUMBER}/locations/global/catalogs/{CATALOG_ID} + */ + // const parent = 'abc123' + + // Imports the Retail library + const {MerchantCenterAccountLinkServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new MerchantCenterAccountLinkServiceClient(); + + async function callListMerchantCenterAccountLinks() { + // Construct request + const request = { + parent, + }; + + // Run request + const response = await retailClient.listMerchantCenterAccountLinks(request); + console.log(response); + } + + callListMerchantCenterAccountLinks(); + // [END retail_v2alpha_generated_MerchantCenterAccountLinkService_ListMerchantCenterAccountLinks_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.create_model.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.create_model.js new file mode 100644 index 00000000000..1e705fb6fca --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.create_model.js @@ -0,0 +1,74 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, model) { + // [START retail_v2alpha_generated_ModelService_CreateModel_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent resource under which to create the model. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + */ + // const parent = 'abc123' + /** + * Required. The payload of the Model google.cloud.retail.v2alpha.Model to + * create. + */ + // const model = {} + /** + * Optional. Whether to run a dry run to validate the request (without + * actually creating the model). + */ + // const dryRun = true + + // Imports the Retail library + const {ModelServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ModelServiceClient(); + + async function callCreateModel() { + // Construct request + const request = { + parent, + model, + }; + + // Run request + const [operation] = await retailClient.createModel(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateModel(); + // [END retail_v2alpha_generated_ModelService_CreateModel_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.delete_model.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.delete_model.js new file mode 100644 index 00000000000..9e0fa545ecb --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.delete_model.js @@ -0,0 +1,63 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by 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_ModelService_DeleteModel_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the + * Model google.cloud.retail.v2alpha.Model to delete. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + */ + // const name = 'abc123' + + // Imports the Retail library + const {ModelServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ModelServiceClient(); + + async function callDeleteModel() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.deleteModel(request); + console.log(response); + } + + callDeleteModel(); + // [END retail_v2alpha_generated_ModelService_DeleteModel_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.get_model.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.get_model.js new file mode 100644 index 00000000000..082a17dc5fd --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.get_model.js @@ -0,0 +1,63 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by 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_ModelService_GetModel_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the + * Model google.cloud.retail.v2alpha.Model to get. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog}/models/{model_id}` + */ + // const name = 'abc123' + + // Imports the Retail library + const {ModelServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ModelServiceClient(); + + async function callGetModel() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.getModel(request); + console.log(response); + } + + callGetModel(); + // [END retail_v2alpha_generated_ModelService_GetModel_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.list_models.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.list_models.js new file mode 100644 index 00000000000..2985c1214f3 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.list_models.js @@ -0,0 +1,75 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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_ModelService_ListModels_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent for which to list models. + * 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 `ListModels` + * call. Provide this to retrieve the subsequent page. + */ + // const pageToken = 'abc123' + + // Imports the Retail library + const {ModelServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ModelServiceClient(); + + async function callListModels() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await retailClient.listModelsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListModels(); + // [END retail_v2alpha_generated_ModelService_ListModels_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.pause_model.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.pause_model.js new file mode 100644 index 00000000000..d8d1fc88cfb --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.pause_model.js @@ -0,0 +1,63 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by 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_ModelService_PauseModel_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the model to pause. + * Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + */ + // const name = 'abc123' + + // Imports the Retail library + const {ModelServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ModelServiceClient(); + + async function callPauseModel() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.pauseModel(request); + console.log(response); + } + + callPauseModel(); + // [END retail_v2alpha_generated_ModelService_PauseModel_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.resume_model.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.resume_model.js new file mode 100644 index 00000000000..03238aa786a --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.resume_model.js @@ -0,0 +1,63 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by 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_ModelService_ResumeModel_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the model to resume. + * Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + */ + // const name = 'abc123' + + // Imports the Retail library + const {ModelServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ModelServiceClient(); + + async function callResumeModel() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.resumeModel(request); + console.log(response); + } + + callResumeModel(); + // [END retail_v2alpha_generated_ModelService_ResumeModel_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.tune_model.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.tune_model.js new file mode 100644 index 00000000000..3a42c227e07 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.tune_model.js @@ -0,0 +1,64 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by 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_ModelService_TuneModel_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the model to tune. + * Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + */ + // const name = 'abc123' + + // Imports the Retail library + const {ModelServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ModelServiceClient(); + + async function callTuneModel() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await retailClient.tuneModel(request); + const [response] = await operation.promise(); + console.log(response); + } + + callTuneModel(); + // [END retail_v2alpha_generated_ModelService_TuneModel_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.update_model.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.update_model.js new file mode 100644 index 00000000000..d9464299239 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.update_model.js @@ -0,0 +1,67 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(model) { + // [START retail_v2alpha_generated_ModelService_UpdateModel_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The body of the updated + * Model google.cloud.retail.v2alpha.Model. + */ + // const model = {} + /** + * Optional. Indicates which fields in the provided 'model' to + * update. If not set, by default updates all fields. + */ + // const updateMask = {} + + // Imports the Retail library + const {ModelServiceClient} = require('@google-cloud/retail').v2alpha; + + // Instantiates a client + const retailClient = new ModelServiceClient(); + + async function callUpdateModel() { + // Construct request + const request = { + model, + }; + + // Run request + const response = await retailClient.updateModel(request); + console.log(response); + } + + callUpdateModel(); + // [END retail_v2alpha_generated_ModelService_UpdateModel_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/prediction_service.predict.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/prediction_service.predict.js new file mode 100644 index 00000000000..5b950b62942 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/prediction_service.predict.js @@ -0,0 +1,187 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of the format: + * `{placement=projects/* /locations/global/catalogs/default_catalog/servingConfigs/*}` + * or + * `{placement=projects/* /locations/global/catalogs/default_catalog/placements/*}`. + * We recommend using the `servingConfigs` resource. `placements` is a legacy + * resource. + * The ID of the Recommendations AI serving config or placement. + * Before you can request predictions from your model, you must create at + * least one serving config or placement for it. For more information, see + * Manage serving configs + * (https://cloud.google.com/retail/docs/manage-configs). + * The full list of available serving configs can be seen at + * https://console.cloud.google.com/ai/retail/catalogs/default_catalog/configs + */ + // 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.v2alpha.UserEvent.visitor_id or + * UserInfo.user_id google.cloud.retail.v2alpha.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.v2alpha.UserEvent.visitor_id to + * a random unique ID and leave + * UserInfo.user_id google.cloud.retail.v2alpha.UserInfo.user_id unset. + */ + // const userEvent = {} + /** + * Maximum number of results to return. 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 + /** + * This field is not used; leave it unset. + */ + // 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 *no* + * results. If instead you want empty result sets to return generic + * (unfiltered) popular products, set `strictFiltering` to False in + * `PredictRequest.params`. Note that the API will never return items with + * storageStatus of "EXPIRED" or "DELETED" regardless of filter choices. + * If `filterSyntaxV2` is set to true under the `params` field, then + * attribute-based expressions are expected instead of the above described + * tag-based syntax. Examples: + * * (colors: ANY("Red", "Blue")) AND NOT (categories: ANY("Phones")) + * * (availability: ANY("IN_STOCK")) AND + * (colors: ANY("Red") OR categories: ANY("Phones")) + * For more information, see + * Filter recommendations (https://cloud.google.com/retail/docs/filter-recs). + */ + // 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 a 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. + * * `filterSyntaxV2`: Boolean. False by default. If set to true, the `filter` + * field is interpreteted according to the new, attribute-based syntax. + */ + // 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.add_fulfillment_places.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.add_fulfillment_places.js new file mode 100644 index 00000000000..dc07e51c740 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.add_fulfillment_places.js @@ -0,0 +1,119 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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 google.cloud.retail.v2alpha.FulfillmentInfo.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/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.add_local_inventories.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.add_local_inventories.js new file mode 100644 index 00000000000..08bd0ee5d9e --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.add_local_inventories.js @@ -0,0 +1,103 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.create_product.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.create_product.js new file mode 100644 index 00000000000..7dc33678d7a --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.create_product.js @@ -0,0 +1,83 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.delete_product.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.delete_product.js new file mode 100644 index 00000000000..9b4674a82e3 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.delete_product.js @@ -0,0 +1,89 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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' + /** + * This value only applies to the case when the target product is of type + * PRIMARY. + * When deleting a product of VARIANT/COLLECTION type, this value + * will be ignored. + * When set to true, the subsequent variant products will be + * deleted. + * When set to false, if the primary product has active variant products, an + * error will be returned. + */ + // const force = true + + // 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.get_product.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.get_product.js new file mode 100644 index 00000000000..7a5236a0119 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.get_product.js @@ -0,0 +1,68 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.import_products.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.import_products.js new file mode 100644 index 00000000000..40eba2dd035 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.import_products.js @@ -0,0 +1,107 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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, all fields are updated. + */ + // 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 = {} + /** + * Full Pub/Sub topic name for receiving notification. If this field is set, + * when the import is finished, a notification is sent to + * specified Pub/Sub topic. The message data is 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.v2alpha.ImportProductsRequest.parent. + * Make sure that `service-@gcp-sa-retail.iam.gserviceaccount.com` has the + * `pubsub.topics.publish` IAM permission on the topic. + */ + // const notificationPubsubTopic = 'abc123' + /** + * If true, this performs the FULL import even if it would delete a large + * proportion of the products in the default branch, which could potentially + * cause outages if you have live predict/search traffic. + * Only supported when + * ImportProductsRequest.reconciliation_mode google.cloud.retail.v2alpha.ImportProductsRequest.reconciliation_mode + * is set to `FULL`. + */ + // const skipDefaultBranchProtection = true + + // 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.list_products.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.list_products.js new file mode 100644 index 00000000000..4f5f5f4f683 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.list_products.js @@ -0,0 +1,144 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.purge_products.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.purge_products.js new file mode 100644 index 00000000000..a2048e8c732 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.purge_products.js @@ -0,0 +1,104 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.remove_fulfillment_places.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.remove_fulfillment_places.js new file mode 100644 index 00000000000..7b428a62505 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.remove_fulfillment_places.js @@ -0,0 +1,115 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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 google.cloud.retail.v2alpha.FulfillmentInfo.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/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.remove_local_inventories.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.remove_local_inventories.js new file mode 100644 index 00000000000..4ccae287ae8 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.remove_local_inventories.js @@ -0,0 +1,88 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.set_inventory.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.set_inventory.js new file mode 100644 index 00000000000..e283078fe37 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.set_inventory.js @@ -0,0 +1,131 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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 google.cloud.retail.v2alpha.Product.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 google.cloud.retail.v2alpha.Product.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 google.cloud.retail.v2alpha.Product.fulfillment_info + * * Checks that only the desired fulfillment info types have empty + * SetInventoryRequest.inventory.fulfillment_info.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.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, + * ProductService.UpdateProduct google.cloud.retail.v2alpha.ProductService.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/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.update_product.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.update_product.js new file mode 100644 index 00000000000..6ea3f997089 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.update_product.js @@ -0,0 +1,87 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The product 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. + * 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.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/google-cloud-retail/v2alpha/samples/generated/v2alpha/search_service.search.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/search_service.search.js new file mode 100644 index 00000000000..eda0a647bf0 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/search_service.search.js @@ -0,0 +1,332 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the Retail Search serving config, such as + * `projects/* /locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` + * or the name of the legacy placement resource, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. + * This field is used to identify the serving config 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.v2alpha.SearchRequest.filter and + * page_categories google.cloud.retail.v2alpha.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.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 200 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 google.cloud.retail.v2alpha.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.local_inventories.attributes google.cloud.retail.v2alpha.LocalInventory.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. Must be set 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, 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. + * Notice that if both + * ServingConfig.personalization_spec google.cloud.retail.v2alpha.ServingConfig.personalization_spec + * and + * SearchRequest.personalization_spec google.cloud.retail.v2alpha.SearchRequest.personalization_spec + * are set. + * SearchRequest.personalization_spec google.cloud.retail.v2alpha.SearchRequest.personalization_spec + * will override + * ServingConfig.personalization_spec google.cloud.retail.v2alpha.ServingConfig.personalization_spec. + */ + // 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 = {} + /** + * The entity for customers that may run multiple different entities, domains, + * sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, + * `google.com`, `youtube.com`, etc. + * If this is set, it should be exactly matched with + * UserEvent.entity google.cloud.retail.v2alpha.UserEvent.entity to get + * search results boosted by entity. + */ + // const entity = 'abc123' + + // 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.add_control.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.add_control.js new file mode 100644 index 00000000000..22f78550d0c --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.add_control.js @@ -0,0 +1,68 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.create_serving_config.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.create_serving_config.js new file mode 100644 index 00000000000..fc644a3a6a9 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.create_serving_config.js @@ -0,0 +1,75 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.delete_serving_config.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.delete_serving_config.js new file mode 100644 index 00000000000..5c405e74f43 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.delete_serving_config.js @@ -0,0 +1,62 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.get_serving_config.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.get_serving_config.js new file mode 100644 index 00000000000..32e33502e80 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.get_serving_config.js @@ -0,0 +1,62 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.list_serving_configs.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.list_serving_configs.js new file mode 100644 index 00000000000..47b48b2b327 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.list_serving_configs.js @@ -0,0 +1,75 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.remove_control.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.remove_control.js new file mode 100644 index 00000000000..d5ee628f5a6 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.remove_control.js @@ -0,0 +1,68 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.update_serving_config.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.update_serving_config.js new file mode 100644 index 00000000000..7d7404c54e3 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.update_serving_config.js @@ -0,0 +1,69 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/snippet_metadata.google.cloud.retail.v2alpha.json b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/snippet_metadata.google.cloud.retail.v2alpha.json new file mode 100644 index 00000000000..d120273a41b --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/snippet_metadata.google.cloud.retail.v2alpha.json @@ -0,0 +1,2735 @@ +{ + "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": 78, + "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": 65, + "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": 76, + "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": 53, + "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": 54, + "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": 70, + "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": 54, + "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": 62, + "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": 60, + "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": 60, + "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_BatchRemoveCatalogAttributes_async", + "title": "CatalogService batchRemoveCatalogAttributes Sample", + "origin": "API_DEFINITION", + "description": " Removes all specified [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute]s from the [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig].", + "canonical": true, + "file": "catalog_service.batch_remove_catalog_attributes.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BatchRemoveCatalogAttributes", + "fullName": "google.cloud.retail.v2alpha.CatalogService.BatchRemoveCatalogAttributes", + "async": true, + "parameters": [ + { + "name": "attributes_config", + "type": "TYPE_STRING" + }, + { + "name": "attribute_keys", + "type": "TYPE_STRING[]" + } + ], + "resultType": ".google.cloud.retail.v2alpha.BatchRemoveCatalogAttributesResponse", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" + }, + "method": { + "shortName": "BatchRemoveCatalogAttributes", + "fullName": "google.cloud.retail.v2alpha.CatalogService.BatchRemoveCatalogAttributes", + "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": 68, + "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. Enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "completion_service.complete_query.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 129, + "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" + }, + { + "name": "enable_attribute_suggestions", + "type": "TYPE_BOOL" + }, + { + "name": "entity", + "type": "TYPE_STRING" + } + ], + "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. 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": 68, + "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": 67, + "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": 54, + "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 update does not exist, a NOT_FOUND error is returned.", + "canonical": true, + "file": "control_service.update_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 61, + "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": 54, + "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 by their parent [Catalog][google.cloud.retail.v2alpha.Catalog].", + "canonical": true, + "file": "control_service.list_controls.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 74, + "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_MerchantCenterAccountLinkService_ListMerchantCenterAccountLinks_async", + "title": "CatalogService listMerchantCenterAccountLinks Sample", + "origin": "API_DEFINITION", + "description": " Lists all [MerchantCenterAccountLink][google.cloud.retail.v2alpha.MerchantCenterAccountLink]s under the specified parent [Catalog][google.cloud.retail.v2alpha.Catalog].", + "canonical": true, + "file": "merchant_center_account_link_service.list_merchant_center_account_links.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListMerchantCenterAccountLinks", + "fullName": "google.cloud.retail.v2alpha.MerchantCenterAccountLinkService.ListMerchantCenterAccountLinks", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.ListMerchantCenterAccountLinksResponse", + "client": { + "shortName": "MerchantCenterAccountLinkServiceClient", + "fullName": "google.cloud.retail.v2alpha.MerchantCenterAccountLinkServiceClient" + }, + "method": { + "shortName": "ListMerchantCenterAccountLinks", + "fullName": "google.cloud.retail.v2alpha.MerchantCenterAccountLinkService.ListMerchantCenterAccountLinks", + "service": { + "shortName": "MerchantCenterAccountLinkService", + "fullName": "google.cloud.retail.v2alpha.MerchantCenterAccountLinkService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_MerchantCenterAccountLinkService_CreateMerchantCenterAccountLink_async", + "title": "CatalogService createMerchantCenterAccountLink Sample", + "origin": "API_DEFINITION", + "description": " Creates a [MerchantCenterAccountLink][google.cloud.retail.v2alpha.MerchantCenterAccountLink].", + "canonical": true, + "file": "merchant_center_account_link_service.create_merchant_center_account_link.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateMerchantCenterAccountLink", + "fullName": "google.cloud.retail.v2alpha.MerchantCenterAccountLinkService.CreateMerchantCenterAccountLink", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "merchant_center_account_link", + "type": ".google.cloud.retail.v2alpha.MerchantCenterAccountLink" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "MerchantCenterAccountLinkServiceClient", + "fullName": "google.cloud.retail.v2alpha.MerchantCenterAccountLinkServiceClient" + }, + "method": { + "shortName": "CreateMerchantCenterAccountLink", + "fullName": "google.cloud.retail.v2alpha.MerchantCenterAccountLinkService.CreateMerchantCenterAccountLink", + "service": { + "shortName": "MerchantCenterAccountLinkService", + "fullName": "google.cloud.retail.v2alpha.MerchantCenterAccountLinkService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_MerchantCenterAccountLinkService_DeleteMerchantCenterAccountLink_async", + "title": "CatalogService deleteMerchantCenterAccountLink Sample", + "origin": "API_DEFINITION", + "description": " Deletes a [MerchantCenterAccountLink][google.cloud.retail.v2alpha.MerchantCenterAccountLink]. If the [MerchantCenterAccountLink][google.cloud.retail.v2alpha.MerchantCenterAccountLink] to delete does not exist, a NOT_FOUND error is returned.", + "canonical": true, + "file": "merchant_center_account_link_service.delete_merchant_center_account_link.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteMerchantCenterAccountLink", + "fullName": "google.cloud.retail.v2alpha.MerchantCenterAccountLinkService.DeleteMerchantCenterAccountLink", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "MerchantCenterAccountLinkServiceClient", + "fullName": "google.cloud.retail.v2alpha.MerchantCenterAccountLinkServiceClient" + }, + "method": { + "shortName": "DeleteMerchantCenterAccountLink", + "fullName": "google.cloud.retail.v2alpha.MerchantCenterAccountLinkService.DeleteMerchantCenterAccountLink", + "service": { + "shortName": "MerchantCenterAccountLinkService", + "fullName": "google.cloud.retail.v2alpha.MerchantCenterAccountLinkService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ModelService_CreateModel_async", + "title": "CatalogService createModel Sample", + "origin": "API_DEFINITION", + "description": " Creates a new model.", + "canonical": true, + "file": "model_service.create_model.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateModel", + "fullName": "google.cloud.retail.v2alpha.ModelService.CreateModel", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "model", + "type": ".google.cloud.retail.v2alpha.Model" + }, + { + "name": "dry_run", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ModelServiceClient", + "fullName": "google.cloud.retail.v2alpha.ModelServiceClient" + }, + "method": { + "shortName": "CreateModel", + "fullName": "google.cloud.retail.v2alpha.ModelService.CreateModel", + "service": { + "shortName": "ModelService", + "fullName": "google.cloud.retail.v2alpha.ModelService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ModelService_GetModel_async", + "title": "CatalogService getModel Sample", + "origin": "API_DEFINITION", + "description": " Gets a model.", + "canonical": true, + "file": "model_service.get_model.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetModel", + "fullName": "google.cloud.retail.v2alpha.ModelService.GetModel", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.Model", + "client": { + "shortName": "ModelServiceClient", + "fullName": "google.cloud.retail.v2alpha.ModelServiceClient" + }, + "method": { + "shortName": "GetModel", + "fullName": "google.cloud.retail.v2alpha.ModelService.GetModel", + "service": { + "shortName": "ModelService", + "fullName": "google.cloud.retail.v2alpha.ModelService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ModelService_PauseModel_async", + "title": "CatalogService pauseModel Sample", + "origin": "API_DEFINITION", + "description": " Pauses the training of an existing model.", + "canonical": true, + "file": "model_service.pause_model.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PauseModel", + "fullName": "google.cloud.retail.v2alpha.ModelService.PauseModel", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.Model", + "client": { + "shortName": "ModelServiceClient", + "fullName": "google.cloud.retail.v2alpha.ModelServiceClient" + }, + "method": { + "shortName": "PauseModel", + "fullName": "google.cloud.retail.v2alpha.ModelService.PauseModel", + "service": { + "shortName": "ModelService", + "fullName": "google.cloud.retail.v2alpha.ModelService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ModelService_ResumeModel_async", + "title": "CatalogService resumeModel Sample", + "origin": "API_DEFINITION", + "description": " Resumes the training of an existing model.", + "canonical": true, + "file": "model_service.resume_model.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ResumeModel", + "fullName": "google.cloud.retail.v2alpha.ModelService.ResumeModel", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2alpha.Model", + "client": { + "shortName": "ModelServiceClient", + "fullName": "google.cloud.retail.v2alpha.ModelServiceClient" + }, + "method": { + "shortName": "ResumeModel", + "fullName": "google.cloud.retail.v2alpha.ModelService.ResumeModel", + "service": { + "shortName": "ModelService", + "fullName": "google.cloud.retail.v2alpha.ModelService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ModelService_DeleteModel_async", + "title": "CatalogService deleteModel Sample", + "origin": "API_DEFINITION", + "description": " Deletes an existing model.", + "canonical": true, + "file": "model_service.delete_model.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteModel", + "fullName": "google.cloud.retail.v2alpha.ModelService.DeleteModel", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ModelServiceClient", + "fullName": "google.cloud.retail.v2alpha.ModelServiceClient" + }, + "method": { + "shortName": "DeleteModel", + "fullName": "google.cloud.retail.v2alpha.ModelService.DeleteModel", + "service": { + "shortName": "ModelService", + "fullName": "google.cloud.retail.v2alpha.ModelService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ModelService_ListModels_async", + "title": "CatalogService listModels Sample", + "origin": "API_DEFINITION", + "description": " Lists all the models linked to this event store.", + "canonical": true, + "file": "model_service.list_models.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListModels", + "fullName": "google.cloud.retail.v2alpha.ModelService.ListModels", + "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.ListModelsResponse", + "client": { + "shortName": "ModelServiceClient", + "fullName": "google.cloud.retail.v2alpha.ModelServiceClient" + }, + "method": { + "shortName": "ListModels", + "fullName": "google.cloud.retail.v2alpha.ModelService.ListModels", + "service": { + "shortName": "ModelService", + "fullName": "google.cloud.retail.v2alpha.ModelService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ModelService_UpdateModel_async", + "title": "CatalogService updateModel Sample", + "origin": "API_DEFINITION", + "description": " Update of model metadata. Only fields that currently can be updated are: `filtering_option` and `periodic_tuning_state`. If other values are provided, this API method ignores them.", + "canonical": true, + "file": "model_service.update_model.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateModel", + "fullName": "google.cloud.retail.v2alpha.ModelService.UpdateModel", + "async": true, + "parameters": [ + { + "name": "model", + "type": ".google.cloud.retail.v2alpha.Model" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2alpha.Model", + "client": { + "shortName": "ModelServiceClient", + "fullName": "google.cloud.retail.v2alpha.ModelServiceClient" + }, + "method": { + "shortName": "UpdateModel", + "fullName": "google.cloud.retail.v2alpha.ModelService.UpdateModel", + "service": { + "shortName": "ModelService", + "fullName": "google.cloud.retail.v2alpha.ModelService" + } + } + } + }, + { + "regionTag": "retail_v2alpha_generated_ModelService_TuneModel_async", + "title": "CatalogService tuneModel Sample", + "origin": "API_DEFINITION", + "description": " Tunes an existing model.", + "canonical": true, + "file": "model_service.tune_model.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 56, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TuneModel", + "fullName": "google.cloud.retail.v2alpha.ModelService.TuneModel", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ModelServiceClient", + "fullName": "google.cloud.retail.v2alpha.ModelServiceClient" + }, + "method": { + "shortName": "TuneModel", + "fullName": "google.cloud.retail.v2alpha.ModelService.TuneModel", + "service": { + "shortName": "ModelService", + "fullName": "google.cloud.retail.v2alpha.ModelService" + } + } + } + }, + { + "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": 179, + "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": 75, + "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": 60, + "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": 136, + "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": 79, + "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": 81, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteProduct", + "fullName": "google.cloud.retail.v2alpha.ProductService.DeleteProduct", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "force", + "type": "TYPE_BOOL" + } + ], + "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 [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or [ProductService.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": 96, + "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. 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": 99, + "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" + }, + { + "name": "skip_default_branch_protection", + "type": "TYPE_BOOL" + } + ], + "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 is 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 [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. When inventory is updated with [ProductService.CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] and [ProductService.UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct], the specified inventory field value(s) overwrite any existing value(s) while ignoring the last update time for this field. Furthermore, the last update times for the specified inventory fields are overwritten by the times of the [ProductService.CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] or [ProductService.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 is used. If no inventory fields are set in [SetInventoryRequest.set_mask][google.cloud.retail.v2alpha.SetInventoryRequest.set_mask], then any existing inventory information is preserved. Pre-existing inventory information can only be updated with [ProductService.SetInventory][google.cloud.retail.v2alpha.ProductService.SetInventory], [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlaces], and [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces]. The returned [Operation][google.longrunning.Operation]s is obsolete after one day, and the [GetOperation][google.longrunning.Operations.GetOperation] API returns `NOT_FOUND` afterwards. If conflicting updates are issued, the [Operation][google.longrunning.Operation]s associated with the stale updates are not marked as [done][google.longrunning.Operation.done] until they are obsolete.", + "canonical": true, + "file": "product_service.set_inventory.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 123, + "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": " It is recommended to use the [ProductService.AddLocalInventories][google.cloud.retail.v2alpha.ProductService.AddLocalInventories] method instead of [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlaces]. [ProductService.AddLocalInventories][google.cloud.retail.v2alpha.ProductService.AddLocalInventories] achieves the same results but provides more fine-grained control over ingesting local inventory data. 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 [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. The returned [Operation][google.longrunning.Operation]s will be obsolete after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] API will return NOT_FOUND afterwards. If conflicting updates are issued, the [Operation][google.longrunning.Operation]s associated with the stale updates will not be marked as [done][google.longrunning.Operation.done] until being obsolete.", + "canonical": true, + "file": "product_service.add_fulfillment_places.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 111, + "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": " It is recommended to use the [ProductService.RemoveLocalInventories][google.cloud.retail.v2alpha.ProductService.RemoveLocalInventories] method instead of [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces]. [ProductService.RemoveLocalInventories][google.cloud.retail.v2alpha.ProductService.RemoveLocalInventories] achieves the same results but provides more fine-grained control over ingesting local inventory data. 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 [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. The returned [Operation][google.longrunning.Operation]s will be obsolete after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] API will return NOT_FOUND afterwards. If conflicting updates are issued, the [Operation][google.longrunning.Operation]s associated with the stale updates will not be marked as [done][google.longrunning.Operation.done] until being obsolete.", + "canonical": true, + "file": "product_service.remove_fulfillment_places.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 107, + "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 [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. Local inventory information can only be modified using this method. [ProductService.CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] and [ProductService.UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct] has no effect on local inventories. The returned [Operation][google.longrunning.Operation]s will be obsolete after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] API will return NOT_FOUND afterwards. If conflicting updates are issued, the [Operation][google.longrunning.Operation]s associated with the stale updates will not be marked as [done][google.longrunning.Operation.done] until being obsolete.", + "canonical": true, + "file": "product_service.add_local_inventories.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 95, + "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 [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. Local inventory information can only be removed using this method. [ProductService.CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] and [ProductService.UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct] has no effect on local inventories. The returned [Operation][google.longrunning.Operation]s will be obsolete after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] API will return NOT_FOUND afterwards. If conflicting updates are issued, the [Operation][google.longrunning.Operation]s associated with the stale updates will not be marked as [done][google.longrunning.Operation.done] until being obsolete.", + "canonical": true, + "file": "product_service.remove_local_inventories.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "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. Enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "search_service.search.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 324, + "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" + }, + { + "name": "labels", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "spell_correction_spec", + "type": ".google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec" + }, + { + "name": "entity", + "type": "TYPE_STRING" + } + ], + "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": 67, + "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": 54, + "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": 61, + "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": 54, + "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": 67, + "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": 60, + "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": 60, + "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": 66, + "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" + }, + { + "name": "write_async", + "type": "TYPE_BOOL" + } + ], + "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": 85, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CollectUserEvent", + "fullName": "google.cloud.retail.v2alpha.UserEventService.CollectUserEvent", + "async": true, + "parameters": [ + { + "name": "prebuilt_rule", + "type": "TYPE_STRING" + }, + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "user_event", + "type": "TYPE_STRING" + }, + { + "name": "uri", + "type": "TYPE_STRING" + }, + { + "name": "ets", + "type": "TYPE_INT64" + }, + { + "name": "raw_json", + "type": "TYPE_STRING" + } + ], + "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": 86, + "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": 64, + "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 are not annotated with detailed product information for products that are missing from the catalog when the user event is ingested. These events are stored as unjoined events with limited usage on training and serving. You can use this method to start a join operation on specified events with the latest version of product catalog. You can also use this method 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": 62, + "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/google-cloud-retail/v2alpha/samples/generated/v2alpha/user_event_service.collect_user_event.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/user_event_service.collect_user_event.js new file mode 100644 index 00000000000..165f42f95e8 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/user_event_service.collect_user_event.js @@ -0,0 +1,93 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * The prebuilt rule name that can convert a specific type of raw_json. + * For example: "ga4_bq" rule for the GA4 user event schema. + */ + // const prebuiltRule = 'abc123' + /** + * 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 + /** + * An arbitrary serialized JSON string that contains necessary information + * that can comprise a user event. When this field is specified, the + * user_event field will be ignored. Note: line-delimited JSON is not + * supported, a single JSON only. + */ + // const rawJson = 'abc123' + + // 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/user_event_service.import_user_events.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/user_event_service.import_user_events.js new file mode 100644 index 00000000000..ab0256d3fac --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/user_event_service.import_user_events.js @@ -0,0 +1,72 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/user_event_service.purge_user_events.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/user_event_service.purge_user_events.js new file mode 100644 index 00000000000..c68f97440e7 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/user_event_service.purge_user_events.js @@ -0,0 +1,94 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/user_event_service.rejoin_user_events.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/user_event_service.rejoin_user_events.js new file mode 100644 index 00000000000..5bb701e438b --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/user_event_service.rejoin_user_events.js @@ -0,0 +1,70 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/user_event_service.write_user_event.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/user_event_service.write_user_event.js new file mode 100644 index 00000000000..6e9588f1a75 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/user_event_service.write_user_event.js @@ -0,0 +1,74 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent catalog resource name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + */ + // const parent = 'abc123' + /** + * Required. User event to write. + */ + // const userEvent = {} + /** + * If set to true, the user event will be written asynchronously after + * validation, and the API will respond without waiting for the write. + * Therefore, silent failures can occur even if the API returns success. In + * case of silent failures, error messages can be found in Stackdriver logs. + */ + // const writeAsync = true + + // 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/google-cloud-retail/v2alpha/src/index.ts b/owl-bot-staging/google-cloud-retail/v2alpha/src/index.ts new file mode 100644 index 00000000000..83d1892f5b7 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/src/index.ts @@ -0,0 +1,43 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This 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 MerchantCenterAccountLinkServiceClient = v2alpha.MerchantCenterAccountLinkServiceClient; +type MerchantCenterAccountLinkServiceClient = v2alpha.MerchantCenterAccountLinkServiceClient; +const ModelServiceClient = v2alpha.ModelServiceClient; +type ModelServiceClient = v2alpha.ModelServiceClient; +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, MerchantCenterAccountLinkServiceClient, ModelServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, ServingConfigServiceClient, UserEventServiceClient}; +export default {v2alpha, CatalogServiceClient, CompletionServiceClient, ControlServiceClient, MerchantCenterAccountLinkServiceClient, ModelServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, ServingConfigServiceClient, UserEventServiceClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/catalog_service_client.ts b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/catalog_service_client.ts new file mode 100644 index 00000000000..b85b0bf2d0e --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/catalog_service_client.ts @@ -0,0 +1,2369 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/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}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + 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/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new CatalogServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof 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); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + 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}' + ), + merchantCenterAccountLinkPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/merchantCenterAccountLinks/{merchant_center_account_link}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + 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') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',additional_bindings: [{get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/places/*/operations/*}',},{get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2alpha/{name=projects/*/locations/*/operations/*}',},{get: '/v2alpha/{name=projects/*/operations/*}',}], + },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2alpha/{name=projects/*/locations/*/catalogs/*}/operations',additional_bindings: [{get: '/v2alpha/{name=projects/*/locations/*}/operations',},{get: '/v2alpha/{name=projects/*}/operations',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + + this.descriptors.longrunning = { + }; + + // 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 = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.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', 'batchRemoveCatalogAttributes', '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._opts.fallback + ); + + 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 {@link google.cloud.retail.v2alpha.Catalog | 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' + ] = this._gaxModule.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 {@link google.protobuf.Empty | 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' + ] = this._gaxModule.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 {@link google.cloud.retail.v2alpha.GetDefaultBranchResponse | 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' + ] = this._gaxModule.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 {@link google.cloud.retail.v2alpha.CompletionConfig | 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' + ] = this._gaxModule.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 {@link google.cloud.retail.v2alpha.CompletionConfig | 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' + ] = this._gaxModule.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 {@link google.cloud.retail.v2alpha.AttributesConfig | 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' + ] = this._gaxModule.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 {@link google.cloud.retail.v2alpha.AttributesConfig | 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' + ] = this._gaxModule.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 {@link google.cloud.retail.v2alpha.AttributesConfig | 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' + ] = this._gaxModule.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 {@link google.cloud.retail.v2alpha.AttributesConfig | 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'attributes_config': request.attributesConfig ?? '', + }); + this.initialize(); + return this.innerApiCalls.removeCatalogAttribute(request, options, callback); + } +/** + * Removes all specified + * {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute}s from the + * {@link google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.attributesConfig + * Required. The attributes config resource shared by all catalog attributes + * being deleted. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` + * @param {string[]} request.attributeKeys + * Required. The attribute name keys of the + * {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute}s to + * delete. A maximum of 1000 catalog attributes can be deleted in a batch. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.retail.v2alpha.BatchRemoveCatalogAttributesResponse | BatchRemoveCatalogAttributesResponse}. + * Please see 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.batch_remove_catalog_attributes.js + * region_tag:retail_v2alpha_generated_CatalogService_BatchRemoveCatalogAttributes_async + */ + batchRemoveCatalogAttributes( + request?: protos.google.cloud.retail.v2alpha.IBatchRemoveCatalogAttributesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IBatchRemoveCatalogAttributesResponse, + protos.google.cloud.retail.v2alpha.IBatchRemoveCatalogAttributesRequest|undefined, {}|undefined + ]>; + batchRemoveCatalogAttributes( + request: protos.google.cloud.retail.v2alpha.IBatchRemoveCatalogAttributesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IBatchRemoveCatalogAttributesResponse, + protos.google.cloud.retail.v2alpha.IBatchRemoveCatalogAttributesRequest|null|undefined, + {}|null|undefined>): void; + batchRemoveCatalogAttributes( + request: protos.google.cloud.retail.v2alpha.IBatchRemoveCatalogAttributesRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IBatchRemoveCatalogAttributesResponse, + protos.google.cloud.retail.v2alpha.IBatchRemoveCatalogAttributesRequest|null|undefined, + {}|null|undefined>): void; + batchRemoveCatalogAttributes( + request?: protos.google.cloud.retail.v2alpha.IBatchRemoveCatalogAttributesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.IBatchRemoveCatalogAttributesResponse, + protos.google.cloud.retail.v2alpha.IBatchRemoveCatalogAttributesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IBatchRemoveCatalogAttributesResponse, + protos.google.cloud.retail.v2alpha.IBatchRemoveCatalogAttributesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.IBatchRemoveCatalogAttributesResponse, + protos.google.cloud.retail.v2alpha.IBatchRemoveCatalogAttributesRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'attributes_config': request.attributesConfig ?? '', + }); + this.initialize(); + return this.innerApiCalls.batchRemoveCatalogAttributes(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 {@link google.cloud.retail.v2alpha.AttributesConfig | 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' + ] = this._gaxModule.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 {@link google.cloud.retail.v2alpha.Catalog | 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' + ] = this._gaxModule.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 {@link google.cloud.retail.v2alpha.Catalog | 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' + ] = this._gaxModule.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 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 + * {@link google.cloud.retail.v2alpha.Catalog | 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' + ] = this._gaxModule.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 {}, + callSettings + ) as AsyncIterable; + } +/** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + +/** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + +/** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified 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 merchantCenterAccountLink resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} merchant_center_account_link + * @returns {string} Resource name string. + */ + merchantCenterAccountLinkPath(project:string,location:string,catalog:string,merchantCenterAccountLink:string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + merchant_center_account_link: merchantCenterAccountLink, + }); + } + + /** + * Parse the project from MerchantCenterAccountLink resource. + * + * @param {string} merchantCenterAccountLinkName + * A fully-qualified path representing MerchantCenterAccountLink resource. + * @returns {string} A string representing the project. + */ + matchProjectFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).project; + } + + /** + * Parse the location from MerchantCenterAccountLink resource. + * + * @param {string} merchantCenterAccountLinkName + * A fully-qualified path representing MerchantCenterAccountLink resource. + * @returns {string} A string representing the location. + */ + matchLocationFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).location; + } + + /** + * Parse the catalog from MerchantCenterAccountLink resource. + * + * @param {string} merchantCenterAccountLinkName + * A fully-qualified path representing MerchantCenterAccountLink resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).catalog; + } + + /** + * Parse the merchant_center_account_link from MerchantCenterAccountLink resource. + * + * @param {string} merchantCenterAccountLinkName + * A fully-qualified path representing MerchantCenterAccountLink resource. + * @returns {string} A string representing the merchant_center_account_link. + */ + matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).merchant_center_account_link; + } + + /** + * Return a fully-qualified model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project:string,location:string,catalog:string,model:string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * 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(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/catalog_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/catalog_service_client_config.json new file mode 100644 index 00000000000..430dc2ec64e --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/catalog_service_client_config.json @@ -0,0 +1,95 @@ +{ + "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" + }, + "BatchRemoveCatalogAttributes": { + "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/google-cloud-retail/v2alpha/src/v2alpha/catalog_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/catalog_service_proto_list.json new file mode 100644 index 00000000000..b794e38509a --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/catalog_service_proto_list.json @@ -0,0 +1,24 @@ +[ + "../../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/merchant_center_account_link.proto", + "../../protos/google/cloud/retail/v2alpha/merchant_center_account_link_service.proto", + "../../protos/google/cloud/retail/v2alpha/model.proto", + "../../protos/google/cloud/retail/v2alpha/model_service.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/google-cloud-retail/v2alpha/src/v2alpha/completion_service_client.ts b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/completion_service_client.ts new file mode 100644 index 00000000000..2c00d3a878c --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/completion_service_client.ts @@ -0,0 +1,1363 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, LocationsClient, LocationProtos} 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'; +const version = require('../../../package.json').version; + +/** + * Autocomplete service for retail. + * + * This feature is only available for users who have Retail Search enabled. + * 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}; + locationsClient: LocationsClient; + 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/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new CompletionServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof 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); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + 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}' + ), + merchantCenterAccountLinkPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/merchantCenterAccountLinks/{merchant_center_account_link}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + 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. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',additional_bindings: [{get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/places/*/operations/*}',},{get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2alpha/{name=projects/*/locations/*/operations/*}',},{get: '/v2alpha/{name=projects/*/operations/*}',}], + },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2alpha/{name=projects/*/locations/*/catalogs/*}/operations',additional_bindings: [{get: '/v2alpha/{name=projects/*/locations/*}/operations',},{get: '/v2alpha/{name=projects/*}/operations',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).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 = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.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._opts.fallback + ); + + 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. + * 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 + * Note that this field applies for `user-data` dataset only. For requests + * with `cloud-retail` dataset, setting this field has no effect. + * + * 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. We recommend that you + * leave this field empty. + * + * It can 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 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 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 {boolean} request.enableAttributeSuggestions + * If true, attribute suggestions are enabled and provided in response. + * + * This field is only available for "cloud-retail" dataset. + * @param {string} request.entity + * The entity for customers that may run multiple different entities, domains, + * sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, + * `google.com`, `youtube.com`, etc. + * If this is set, it should be exactly matched with + * {@link google.cloud.retail.v2alpha.UserEvent.entity|UserEvent.entity} to get + * per-entity autocomplete results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.retail.v2alpha.CompleteQueryResponse | 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' + ] = this._gaxModule.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. + * 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 is sent to + * specified Pub/Sub topic. The message data is 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' + ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.importCompletionData, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + +/** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + +/** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified 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 merchantCenterAccountLink resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} merchant_center_account_link + * @returns {string} Resource name string. + */ + merchantCenterAccountLinkPath(project:string,location:string,catalog:string,merchantCenterAccountLink:string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + merchant_center_account_link: merchantCenterAccountLink, + }); + } + + /** + * Parse the project from MerchantCenterAccountLink resource. + * + * @param {string} merchantCenterAccountLinkName + * A fully-qualified path representing MerchantCenterAccountLink resource. + * @returns {string} A string representing the project. + */ + matchProjectFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).project; + } + + /** + * Parse the location from MerchantCenterAccountLink resource. + * + * @param {string} merchantCenterAccountLinkName + * A fully-qualified path representing MerchantCenterAccountLink resource. + * @returns {string} A string representing the location. + */ + matchLocationFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).location; + } + + /** + * Parse the catalog from MerchantCenterAccountLink resource. + * + * @param {string} merchantCenterAccountLinkName + * A fully-qualified path representing MerchantCenterAccountLink resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).catalog; + } + + /** + * Parse the merchant_center_account_link from MerchantCenterAccountLink resource. + * + * @param {string} merchantCenterAccountLinkName + * A fully-qualified path representing MerchantCenterAccountLink resource. + * @returns {string} A string representing the merchant_center_account_link. + */ + matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).merchant_center_account_link; + } + + /** + * Return a fully-qualified model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project:string,location:string,catalog:string,model:string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * 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.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/completion_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/completion_service_client_config.json new file mode 100644 index 00000000000..ac2795a5fb1 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2alpha/src/v2alpha/completion_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/completion_service_proto_list.json new file mode 100644 index 00000000000..b794e38509a --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/completion_service_proto_list.json @@ -0,0 +1,24 @@ +[ + "../../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/merchant_center_account_link.proto", + "../../protos/google/cloud/retail/v2alpha/merchant_center_account_link_service.proto", + "../../protos/google/cloud/retail/v2alpha/model.proto", + "../../protos/google/cloud/retail/v2alpha/model_service.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/google-cloud-retail/v2alpha/src/v2alpha/control_service_client.ts b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/control_service_client.ts new file mode 100644 index 00000000000..d866d6af200 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/control_service_client.ts @@ -0,0 +1,1621 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/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}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + 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/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new ControlServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof 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); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + 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}' + ), + merchantCenterAccountLinkPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/merchantCenterAccountLinks/{merchant_center_account_link}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + 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') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',additional_bindings: [{get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/places/*/operations/*}',},{get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2alpha/{name=projects/*/locations/*/operations/*}',},{get: '/v2alpha/{name=projects/*/operations/*}',}], + },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2alpha/{name=projects/*/locations/*/catalogs/*}/operations',additional_bindings: [{get: '/v2alpha/{name=projects/*/locations/*}/operations',},{get: '/v2alpha/{name=projects/*}/operations',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + + this.descriptors.longrunning = { + }; + + // 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 = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.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._opts.fallback + ); + + 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 {@link google.cloud.retail.v2alpha.Control | 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' + ] = this._gaxModule.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 {@link google.protobuf.Empty | 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' + ] = this._gaxModule.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 update 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 {@link google.cloud.retail.v2alpha.Control | 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' + ] = this._gaxModule.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 get. 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 {@link google.cloud.retail.v2alpha.Control | 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getControl(request, options, callback); + } + + /** + * Lists all Controls by their parent + * {@link google.cloud.retail.v2alpha.Catalog|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 {@link google.cloud.retail.v2alpha.Control | 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' + ] = this._gaxModule.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 {@link google.cloud.retail.v2alpha.Control | 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' + ] = this._gaxModule.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 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 + * {@link google.cloud.retail.v2alpha.Control | 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' + ] = this._gaxModule.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 {}, + callSettings + ) as AsyncIterable; + } +/** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + +/** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + +/** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified 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 merchantCenterAccountLink resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} merchant_center_account_link + * @returns {string} Resource name string. + */ + merchantCenterAccountLinkPath(project:string,location:string,catalog:string,merchantCenterAccountLink:string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + merchant_center_account_link: merchantCenterAccountLink, + }); + } + + /** + * Parse the project from MerchantCenterAccountLink resource. + * + * @param {string} merchantCenterAccountLinkName + * A fully-qualified path representing MerchantCenterAccountLink resource. + * @returns {string} A string representing the project. + */ + matchProjectFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).project; + } + + /** + * Parse the location from MerchantCenterAccountLink resource. + * + * @param {string} merchantCenterAccountLinkName + * A fully-qualified path representing MerchantCenterAccountLink resource. + * @returns {string} A string representing the location. + */ + matchLocationFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).location; + } + + /** + * Parse the catalog from MerchantCenterAccountLink resource. + * + * @param {string} merchantCenterAccountLinkName + * A fully-qualified path representing MerchantCenterAccountLink resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).catalog; + } + + /** + * Parse the merchant_center_account_link from MerchantCenterAccountLink resource. + * + * @param {string} merchantCenterAccountLinkName + * A fully-qualified path representing MerchantCenterAccountLink resource. + * @returns {string} A string representing the merchant_center_account_link. + */ + matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).merchant_center_account_link; + } + + /** + * Return a fully-qualified model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project:string,location:string,catalog:string,model:string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * 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(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/control_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/control_service_client_config.json new file mode 100644 index 00000000000..9a86d786b23 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2alpha/src/v2alpha/control_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/control_service_proto_list.json new file mode 100644 index 00000000000..b794e38509a --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/control_service_proto_list.json @@ -0,0 +1,24 @@ +[ + "../../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/merchant_center_account_link.proto", + "../../protos/google/cloud/retail/v2alpha/merchant_center_account_link_service.proto", + "../../protos/google/cloud/retail/v2alpha/model.proto", + "../../protos/google/cloud/retail/v2alpha/model_service.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/google-cloud-retail/v2alpha/src/v2alpha/gapic_metadata.json b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/gapic_metadata.json new file mode 100644 index 00000000000..0c8eeb47a17 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/gapic_metadata.json @@ -0,0 +1,733 @@ +{ + "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" + ] + }, + "BatchRemoveCatalogAttributes": { + "methods": [ + "batchRemoveCatalogAttributes" + ] + }, + "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" + ] + }, + "BatchRemoveCatalogAttributes": { + "methods": [ + "batchRemoveCatalogAttributes" + ] + }, + "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" + ] + } + } + } + } + }, + "MerchantCenterAccountLinkService": { + "clients": { + "grpc": { + "libraryClient": "MerchantCenterAccountLinkServiceClient", + "rpcs": { + "ListMerchantCenterAccountLinks": { + "methods": [ + "listMerchantCenterAccountLinks" + ] + }, + "DeleteMerchantCenterAccountLink": { + "methods": [ + "deleteMerchantCenterAccountLink" + ] + }, + "CreateMerchantCenterAccountLink": { + "methods": [ + "createMerchantCenterAccountLink" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "MerchantCenterAccountLinkServiceClient", + "rpcs": { + "ListMerchantCenterAccountLinks": { + "methods": [ + "listMerchantCenterAccountLinks" + ] + }, + "DeleteMerchantCenterAccountLink": { + "methods": [ + "deleteMerchantCenterAccountLink" + ] + }, + "CreateMerchantCenterAccountLink": { + "methods": [ + "createMerchantCenterAccountLink" + ] + } + } + } + } + }, + "ModelService": { + "clients": { + "grpc": { + "libraryClient": "ModelServiceClient", + "rpcs": { + "GetModel": { + "methods": [ + "getModel" + ] + }, + "PauseModel": { + "methods": [ + "pauseModel" + ] + }, + "ResumeModel": { + "methods": [ + "resumeModel" + ] + }, + "DeleteModel": { + "methods": [ + "deleteModel" + ] + }, + "UpdateModel": { + "methods": [ + "updateModel" + ] + }, + "CreateModel": { + "methods": [ + "createModel" + ] + }, + "TuneModel": { + "methods": [ + "tuneModel" + ] + }, + "ListModels": { + "methods": [ + "listModels", + "listModelsStream", + "listModelsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ModelServiceClient", + "rpcs": { + "GetModel": { + "methods": [ + "getModel" + ] + }, + "PauseModel": { + "methods": [ + "pauseModel" + ] + }, + "ResumeModel": { + "methods": [ + "resumeModel" + ] + }, + "DeleteModel": { + "methods": [ + "deleteModel" + ] + }, + "UpdateModel": { + "methods": [ + "updateModel" + ] + }, + "CreateModel": { + "methods": [ + "createModel" + ] + }, + "TuneModel": { + "methods": [ + "tuneModel" + ] + }, + "ListModels": { + "methods": [ + "listModels", + "listModelsStream", + "listModelsAsync" + ] + } + } + } + } + }, + "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/google-cloud-retail/v2alpha/src/v2alpha/index.ts b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/index.ts new file mode 100644 index 00000000000..2dbce074db8 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/index.ts @@ -0,0 +1,28 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {MerchantCenterAccountLinkServiceClient} from './merchant_center_account_link_service_client'; +export {ModelServiceClient} from './model_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/google-cloud-retail/v2alpha/src/v2alpha/merchant_center_account_link_service_client.ts b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/merchant_center_account_link_service_client.ts new file mode 100644 index 00000000000..b0a04656dff --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/merchant_center_account_link_service_client.ts @@ -0,0 +1,1357 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, LocationsClient, LocationProtos} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2alpha/merchant_center_account_link_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './merchant_center_account_link_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Merchant Center Link service to link a Branch to a Merchant Center Account. + * @class + * @memberof v2alpha + */ +export class MerchantCenterAccountLinkServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + merchantCenterAccountLinkServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of MerchantCenterAccountLinkServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new MerchantCenterAccountLinkServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof MerchantCenterAccountLinkServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + 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}' + ), + merchantCenterAccountLinkPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/merchantCenterAccountLinks/{merchant_center_account_link}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + 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. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',additional_bindings: [{get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/places/*/operations/*}',},{get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2alpha/{name=projects/*/locations/*/operations/*}',},{get: '/v2alpha/{name=projects/*/operations/*}',}], + },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2alpha/{name=projects/*/locations/*/catalogs/*}/operations',additional_bindings: [{get: '/v2alpha/{name=projects/*/locations/*}/operations',},{get: '/v2alpha/{name=projects/*}/operations',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const createMerchantCenterAccountLinkResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.MerchantCenterAccountLink') as gax.protobuf.Type; + const createMerchantCenterAccountLinkMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.CreateMerchantCenterAccountLinkMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + createMerchantCenterAccountLink: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createMerchantCenterAccountLinkResponse.decode.bind(createMerchantCenterAccountLinkResponse), + createMerchantCenterAccountLinkMetadata.decode.bind(createMerchantCenterAccountLinkMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2alpha.MerchantCenterAccountLinkService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.merchantCenterAccountLinkServiceStub) { + return this.merchantCenterAccountLinkServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2alpha.MerchantCenterAccountLinkService. + this.merchantCenterAccountLinkServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2alpha.MerchantCenterAccountLinkService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2alpha.MerchantCenterAccountLinkService, + 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 merchantCenterAccountLinkServiceStubMethods = + ['listMerchantCenterAccountLinks', 'createMerchantCenterAccountLink', 'deleteMerchantCenterAccountLink']; + for (const methodName of merchantCenterAccountLinkServiceStubMethods) { + const callPromise = this.merchantCenterAccountLinkServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.merchantCenterAccountLinkServiceStub; + } + + /** + * 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 -- + // ------------------- +/** + * Lists all + * {@link google.cloud.retail.v2alpha.MerchantCenterAccountLink|MerchantCenterAccountLink}s + * under the specified parent {@link google.cloud.retail.v2alpha.Catalog|Catalog}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent Catalog of the resource. + * It must match this format: + * projects/{PROJECT_NUMBER}/locations/global/catalogs/{CATALOG_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 {@link google.cloud.retail.v2alpha.ListMerchantCenterAccountLinksResponse | ListMerchantCenterAccountLinksResponse}. + * Please see 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/merchant_center_account_link_service.list_merchant_center_account_links.js + * region_tag:retail_v2alpha_generated_MerchantCenterAccountLinkService_ListMerchantCenterAccountLinks_async + */ + listMerchantCenterAccountLinks( + request?: protos.google.cloud.retail.v2alpha.IListMerchantCenterAccountLinksRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IListMerchantCenterAccountLinksResponse, + protos.google.cloud.retail.v2alpha.IListMerchantCenterAccountLinksRequest|undefined, {}|undefined + ]>; + listMerchantCenterAccountLinks( + request: protos.google.cloud.retail.v2alpha.IListMerchantCenterAccountLinksRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IListMerchantCenterAccountLinksResponse, + protos.google.cloud.retail.v2alpha.IListMerchantCenterAccountLinksRequest|null|undefined, + {}|null|undefined>): void; + listMerchantCenterAccountLinks( + request: protos.google.cloud.retail.v2alpha.IListMerchantCenterAccountLinksRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IListMerchantCenterAccountLinksResponse, + protos.google.cloud.retail.v2alpha.IListMerchantCenterAccountLinksRequest|null|undefined, + {}|null|undefined>): void; + listMerchantCenterAccountLinks( + request?: protos.google.cloud.retail.v2alpha.IListMerchantCenterAccountLinksRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.IListMerchantCenterAccountLinksResponse, + protos.google.cloud.retail.v2alpha.IListMerchantCenterAccountLinksRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IListMerchantCenterAccountLinksResponse, + protos.google.cloud.retail.v2alpha.IListMerchantCenterAccountLinksRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.IListMerchantCenterAccountLinksResponse, + protos.google.cloud.retail.v2alpha.IListMerchantCenterAccountLinksRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listMerchantCenterAccountLinks(request, options, callback); + } +/** + * Deletes a + * {@link google.cloud.retail.v2alpha.MerchantCenterAccountLink|MerchantCenterAccountLink}. + * If the + * {@link google.cloud.retail.v2alpha.MerchantCenterAccountLink|MerchantCenterAccountLink} + * 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. Full resource name. Format: + * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/merchantCenterAccountLinks/{merchant_center_account_link_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 {@link google.protobuf.Empty | 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/merchant_center_account_link_service.delete_merchant_center_account_link.js + * region_tag:retail_v2alpha_generated_MerchantCenterAccountLinkService_DeleteMerchantCenterAccountLink_async + */ + deleteMerchantCenterAccountLink( + request?: protos.google.cloud.retail.v2alpha.IDeleteMerchantCenterAccountLinkRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteMerchantCenterAccountLinkRequest|undefined, {}|undefined + ]>; + deleteMerchantCenterAccountLink( + request: protos.google.cloud.retail.v2alpha.IDeleteMerchantCenterAccountLinkRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteMerchantCenterAccountLinkRequest|null|undefined, + {}|null|undefined>): void; + deleteMerchantCenterAccountLink( + request: protos.google.cloud.retail.v2alpha.IDeleteMerchantCenterAccountLinkRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteMerchantCenterAccountLinkRequest|null|undefined, + {}|null|undefined>): void; + deleteMerchantCenterAccountLink( + request?: protos.google.cloud.retail.v2alpha.IDeleteMerchantCenterAccountLinkRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteMerchantCenterAccountLinkRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteMerchantCenterAccountLinkRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteMerchantCenterAccountLinkRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteMerchantCenterAccountLink(request, options, callback); + } + +/** + * Creates a + * {@link google.cloud.retail.v2alpha.MerchantCenterAccountLink|MerchantCenterAccountLink}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The branch resource where this MerchantCenterAccountLink will be + * created. Format: + * projects/{PROJECT_NUMBER}/locations/global/catalogs/{CATALOG_ID}} + * @param {google.cloud.retail.v2alpha.MerchantCenterAccountLink} request.merchantCenterAccountLink + * Required. The + * {@link google.cloud.retail.v2alpha.MerchantCenterAccountLink|MerchantCenterAccountLink} + * to create. + * + * If the caller does not have permission to create the + * {@link google.cloud.retail.v2alpha.MerchantCenterAccountLink|MerchantCenterAccountLink}, + * regardless of whether or not it exists, a PERMISSION_DENIED 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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [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/merchant_center_account_link_service.create_merchant_center_account_link.js + * region_tag:retail_v2alpha_generated_MerchantCenterAccountLinkService_CreateMerchantCenterAccountLink_async + */ + createMerchantCenterAccountLink( + request?: protos.google.cloud.retail.v2alpha.ICreateMerchantCenterAccountLinkRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createMerchantCenterAccountLink( + request: protos.google.cloud.retail.v2alpha.ICreateMerchantCenterAccountLinkRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createMerchantCenterAccountLink( + request: protos.google.cloud.retail.v2alpha.ICreateMerchantCenterAccountLinkRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createMerchantCenterAccountLink( + request?: protos.google.cloud.retail.v2alpha.ICreateMerchantCenterAccountLinkRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createMerchantCenterAccountLink(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createMerchantCenterAccountLink()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [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/merchant_center_account_link_service.create_merchant_center_account_link.js + * region_tag:retail_v2alpha_generated_MerchantCenterAccountLinkService_CreateMerchantCenterAccountLink_async + */ + async checkCreateMerchantCenterAccountLinkProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createMerchantCenterAccountLink, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + +/** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + +/** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified 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 merchantCenterAccountLink resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} merchant_center_account_link + * @returns {string} Resource name string. + */ + merchantCenterAccountLinkPath(project:string,location:string,catalog:string,merchantCenterAccountLink:string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + merchant_center_account_link: merchantCenterAccountLink, + }); + } + + /** + * Parse the project from MerchantCenterAccountLink resource. + * + * @param {string} merchantCenterAccountLinkName + * A fully-qualified path representing MerchantCenterAccountLink resource. + * @returns {string} A string representing the project. + */ + matchProjectFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).project; + } + + /** + * Parse the location from MerchantCenterAccountLink resource. + * + * @param {string} merchantCenterAccountLinkName + * A fully-qualified path representing MerchantCenterAccountLink resource. + * @returns {string} A string representing the location. + */ + matchLocationFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).location; + } + + /** + * Parse the catalog from MerchantCenterAccountLink resource. + * + * @param {string} merchantCenterAccountLinkName + * A fully-qualified path representing MerchantCenterAccountLink resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).catalog; + } + + /** + * Parse the merchant_center_account_link from MerchantCenterAccountLink resource. + * + * @param {string} merchantCenterAccountLinkName + * A fully-qualified path representing MerchantCenterAccountLink resource. + * @returns {string} A string representing the merchant_center_account_link. + */ + matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).merchant_center_account_link; + } + + /** + * Return a fully-qualified model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project:string,location:string,catalog:string,model:string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * 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.merchantCenterAccountLinkServiceStub && !this._terminated) { + return this.merchantCenterAccountLinkServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/merchant_center_account_link_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/merchant_center_account_link_service_client_config.json new file mode 100644 index 00000000000..218d843e54f --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/merchant_center_account_link_service_client_config.json @@ -0,0 +1,38 @@ +{ + "interfaces": { + "google.cloud.retail.v2alpha.MerchantCenterAccountLinkService": { + "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": { + "ListMerchantCenterAccountLinks": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateMerchantCenterAccountLink": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteMerchantCenterAccountLink": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/merchant_center_account_link_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/merchant_center_account_link_service_proto_list.json new file mode 100644 index 00000000000..b794e38509a --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/merchant_center_account_link_service_proto_list.json @@ -0,0 +1,24 @@ +[ + "../../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/merchant_center_account_link.proto", + "../../protos/google/cloud/retail/v2alpha/merchant_center_account_link_service.proto", + "../../protos/google/cloud/retail/v2alpha/model.proto", + "../../protos/google/cloud/retail/v2alpha/model_service.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/google-cloud-retail/v2alpha/src/v2alpha/model_service_client.ts b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/model_service_client.ts new file mode 100644 index 00000000000..37550a76118 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/model_service_client.ts @@ -0,0 +1,1877 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2alpha/model_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './model_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service for performing CRUD operations on models. + * Recommendation models contain all the metadata necessary to generate a set of + * models for the `Predict()` API. A model is queried + * indirectly via a ServingConfig, which associates a model with a + * given Placement (e.g. Frequently Bought Together on Home Page). + * + * This service allows you to do the following: + * + * * Initiate training of a model. + * * Pause training of an existing model. + * * List all the available models along with their metadata. + * * Control their tuning schedule. + * @class + * @memberof v2alpha + */ +export class ModelServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + modelServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ModelServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new ModelServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ModelServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + 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}' + ), + merchantCenterAccountLinkPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/merchantCenterAccountLinks/{merchant_center_account_link}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + 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 = { + listModels: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'models') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',additional_bindings: [{get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/places/*/operations/*}',},{get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2alpha/{name=projects/*/locations/*/operations/*}',},{get: '/v2alpha/{name=projects/*/operations/*}',}], + },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2alpha/{name=projects/*/locations/*/catalogs/*}/operations',additional_bindings: [{get: '/v2alpha/{name=projects/*/locations/*}/operations',},{get: '/v2alpha/{name=projects/*}/operations',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const createModelResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.Model') as gax.protobuf.Type; + const createModelMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.CreateModelMetadata') as gax.protobuf.Type; + const tuneModelResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.TuneModelResponse') as gax.protobuf.Type; + const tuneModelMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2alpha.TuneModelMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + createModel: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createModelResponse.decode.bind(createModelResponse), + createModelMetadata.decode.bind(createModelMetadata)), + tuneModel: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + tuneModelResponse.decode.bind(tuneModelResponse), + tuneModelMetadata.decode.bind(tuneModelMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2alpha.ModelService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.modelServiceStub) { + return this.modelServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2alpha.ModelService. + this.modelServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2alpha.ModelService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2alpha.ModelService, + 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 modelServiceStubMethods = + ['createModel', 'getModel', 'pauseModel', 'resumeModel', 'deleteModel', 'listModels', 'updateModel', 'tuneModel']; + for (const methodName of modelServiceStubMethods) { + const callPromise = this.modelServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.modelServiceStub; + } + + /** + * 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 -- + // ------------------- +/** + * Gets a model. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the + * {@link google.cloud.retail.v2alpha.Model|Model} to get. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog}/models/{model_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 {@link google.cloud.retail.v2alpha.Model | Model}. + * Please see 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/model_service.get_model.js + * region_tag:retail_v2alpha_generated_ModelService_GetModel_async + */ + getModel( + request?: protos.google.cloud.retail.v2alpha.IGetModelRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.IGetModelRequest|undefined, {}|undefined + ]>; + getModel( + request: protos.google.cloud.retail.v2alpha.IGetModelRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.IGetModelRequest|null|undefined, + {}|null|undefined>): void; + getModel( + request: protos.google.cloud.retail.v2alpha.IGetModelRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.IGetModelRequest|null|undefined, + {}|null|undefined>): void; + getModel( + request?: protos.google.cloud.retail.v2alpha.IGetModelRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.IGetModelRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.IGetModelRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.IGetModelRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getModel(request, options, callback); + } +/** + * Pauses the training of an existing model. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the model to pause. + * Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_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 {@link google.cloud.retail.v2alpha.Model | Model}. + * Please see 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/model_service.pause_model.js + * region_tag:retail_v2alpha_generated_ModelService_PauseModel_async + */ + pauseModel( + request?: protos.google.cloud.retail.v2alpha.IPauseModelRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.IPauseModelRequest|undefined, {}|undefined + ]>; + pauseModel( + request: protos.google.cloud.retail.v2alpha.IPauseModelRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.IPauseModelRequest|null|undefined, + {}|null|undefined>): void; + pauseModel( + request: protos.google.cloud.retail.v2alpha.IPauseModelRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.IPauseModelRequest|null|undefined, + {}|null|undefined>): void; + pauseModel( + request?: protos.google.cloud.retail.v2alpha.IPauseModelRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.IPauseModelRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.IPauseModelRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.IPauseModelRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.pauseModel(request, options, callback); + } +/** + * Resumes the training of an existing model. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the model to resume. + * Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_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 {@link google.cloud.retail.v2alpha.Model | Model}. + * Please see 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/model_service.resume_model.js + * region_tag:retail_v2alpha_generated_ModelService_ResumeModel_async + */ + resumeModel( + request?: protos.google.cloud.retail.v2alpha.IResumeModelRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.IResumeModelRequest|undefined, {}|undefined + ]>; + resumeModel( + request: protos.google.cloud.retail.v2alpha.IResumeModelRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.IResumeModelRequest|null|undefined, + {}|null|undefined>): void; + resumeModel( + request: protos.google.cloud.retail.v2alpha.IResumeModelRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.IResumeModelRequest|null|undefined, + {}|null|undefined>): void; + resumeModel( + request?: protos.google.cloud.retail.v2alpha.IResumeModelRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.IResumeModelRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.IResumeModelRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.IResumeModelRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.resumeModel(request, options, callback); + } +/** + * Deletes an existing model. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the + * {@link google.cloud.retail.v2alpha.Model|Model} to delete. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_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 {@link google.protobuf.Empty | 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/model_service.delete_model.js + * region_tag:retail_v2alpha_generated_ModelService_DeleteModel_async + */ + deleteModel( + request?: protos.google.cloud.retail.v2alpha.IDeleteModelRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteModelRequest|undefined, {}|undefined + ]>; + deleteModel( + request: protos.google.cloud.retail.v2alpha.IDeleteModelRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteModelRequest|null|undefined, + {}|null|undefined>): void; + deleteModel( + request: protos.google.cloud.retail.v2alpha.IDeleteModelRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteModelRequest|null|undefined, + {}|null|undefined>): void; + deleteModel( + request?: protos.google.cloud.retail.v2alpha.IDeleteModelRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteModelRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteModelRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2alpha.IDeleteModelRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteModel(request, options, callback); + } +/** + * Update of model metadata. Only fields that + * currently can be updated are: `filtering_option` and + * `periodic_tuning_state`. + * If other values are provided, this API method ignores them. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2alpha.Model} request.model + * Required. The body of the updated + * {@link google.cloud.retail.v2alpha.Model|Model}. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Indicates which fields in the provided 'model' to + * update. If not set, by default updates all fields. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.retail.v2alpha.Model | Model}. + * Please see 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/model_service.update_model.js + * region_tag:retail_v2alpha_generated_ModelService_UpdateModel_async + */ + updateModel( + request?: protos.google.cloud.retail.v2alpha.IUpdateModelRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.IUpdateModelRequest|undefined, {}|undefined + ]>; + updateModel( + request: protos.google.cloud.retail.v2alpha.IUpdateModelRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.IUpdateModelRequest|null|undefined, + {}|null|undefined>): void; + updateModel( + request: protos.google.cloud.retail.v2alpha.IUpdateModelRequest, + callback: Callback< + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.IUpdateModelRequest|null|undefined, + {}|null|undefined>): void; + updateModel( + request?: protos.google.cloud.retail.v2alpha.IUpdateModelRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.IUpdateModelRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.IUpdateModelRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2alpha.IModel, + protos.google.cloud.retail.v2alpha.IUpdateModelRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'model.name': request.model!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateModel(request, options, callback); + } + +/** + * Creates a new model. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource under which to create the model. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + * @param {google.cloud.retail.v2alpha.Model} request.model + * Required. The payload of the {@link google.cloud.retail.v2alpha.Model|Model} to + * create. + * @param {boolean} [request.dryRun] + * Optional. Whether to run a dry run to validate the request (without + * actually creating the model). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [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/model_service.create_model.js + * region_tag:retail_v2alpha_generated_ModelService_CreateModel_async + */ + createModel( + request?: protos.google.cloud.retail.v2alpha.ICreateModelRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createModel( + request: protos.google.cloud.retail.v2alpha.ICreateModelRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createModel( + request: protos.google.cloud.retail.v2alpha.ICreateModelRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createModel( + request?: protos.google.cloud.retail.v2alpha.ICreateModelRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createModel(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createModel()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [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/model_service.create_model.js + * region_tag:retail_v2alpha_generated_ModelService_CreateModel_async + */ + async checkCreateModelProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createModel, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Tunes an existing model. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the model to tune. + * Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [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/model_service.tune_model.js + * region_tag:retail_v2alpha_generated_ModelService_TuneModel_async + */ + tuneModel( + request?: protos.google.cloud.retail.v2alpha.ITuneModelRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + tuneModel( + request: protos.google.cloud.retail.v2alpha.ITuneModelRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + tuneModel( + request: protos.google.cloud.retail.v2alpha.ITuneModelRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + tuneModel( + request?: protos.google.cloud.retail.v2alpha.ITuneModelRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.tuneModel(request, options, callback); + } +/** + * Check the status of the long running operation returned by `tuneModel()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [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/model_service.tune_model.js + * region_tag:retail_v2alpha_generated_ModelService_TuneModel_async + */ + async checkTuneModelProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.tuneModel, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists all the models linked to this event store. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent for which to list models. + * 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 `ListModels` + * 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 {@link google.cloud.retail.v2alpha.Model | Model}. + * 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 `listModelsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listModels( + request?: protos.google.cloud.retail.v2alpha.IListModelsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2alpha.IModel[], + protos.google.cloud.retail.v2alpha.IListModelsRequest|null, + protos.google.cloud.retail.v2alpha.IListModelsResponse + ]>; + listModels( + request: protos.google.cloud.retail.v2alpha.IListModelsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2alpha.IListModelsRequest, + protos.google.cloud.retail.v2alpha.IListModelsResponse|null|undefined, + protos.google.cloud.retail.v2alpha.IModel>): void; + listModels( + request: protos.google.cloud.retail.v2alpha.IListModelsRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2alpha.IListModelsRequest, + protos.google.cloud.retail.v2alpha.IListModelsResponse|null|undefined, + protos.google.cloud.retail.v2alpha.IModel>): void; + listModels( + request?: protos.google.cloud.retail.v2alpha.IListModelsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.retail.v2alpha.IListModelsRequest, + protos.google.cloud.retail.v2alpha.IListModelsResponse|null|undefined, + protos.google.cloud.retail.v2alpha.IModel>, + callback?: PaginationCallback< + protos.google.cloud.retail.v2alpha.IListModelsRequest, + protos.google.cloud.retail.v2alpha.IListModelsResponse|null|undefined, + protos.google.cloud.retail.v2alpha.IModel>): + Promise<[ + protos.google.cloud.retail.v2alpha.IModel[], + protos.google.cloud.retail.v2alpha.IListModelsRequest|null, + protos.google.cloud.retail.v2alpha.IListModelsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listModels(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 for which to list models. + * 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 `ListModels` + * 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 {@link google.cloud.retail.v2alpha.Model | Model} 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 `listModelsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listModelsStream( + request?: protos.google.cloud.retail.v2alpha.IListModelsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listModels']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listModels.createStream( + this.innerApiCalls.listModels as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listModels`, 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 for which to list models. + * 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 `ListModels` + * 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 + * {@link google.cloud.retail.v2alpha.Model | Model}. 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/model_service.list_models.js + * region_tag:retail_v2alpha_generated_ModelService_ListModels_async + */ + listModelsAsync( + request?: protos.google.cloud.retail.v2alpha.IListModelsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listModels']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listModels.asyncIterate( + this.innerApiCalls['listModels'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } +/** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + +/** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + +/** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified 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 merchantCenterAccountLink resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} merchant_center_account_link + * @returns {string} Resource name string. + */ + merchantCenterAccountLinkPath(project:string,location:string,catalog:string,merchantCenterAccountLink:string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + merchant_center_account_link: merchantCenterAccountLink, + }); + } + + /** + * Parse the project from MerchantCenterAccountLink resource. + * + * @param {string} merchantCenterAccountLinkName + * A fully-qualified path representing MerchantCenterAccountLink resource. + * @returns {string} A string representing the project. + */ + matchProjectFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).project; + } + + /** + * Parse the location from MerchantCenterAccountLink resource. + * + * @param {string} merchantCenterAccountLinkName + * A fully-qualified path representing MerchantCenterAccountLink resource. + * @returns {string} A string representing the location. + */ + matchLocationFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).location; + } + + /** + * Parse the catalog from MerchantCenterAccountLink resource. + * + * @param {string} merchantCenterAccountLinkName + * A fully-qualified path representing MerchantCenterAccountLink resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).catalog; + } + + /** + * Parse the merchant_center_account_link from MerchantCenterAccountLink resource. + * + * @param {string} merchantCenterAccountLinkName + * A fully-qualified path representing MerchantCenterAccountLink resource. + * @returns {string} A string representing the merchant_center_account_link. + */ + matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).merchant_center_account_link; + } + + /** + * Return a fully-qualified model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project:string,location:string,catalog:string,model:string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * 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.modelServiceStub && !this._terminated) { + return this.modelServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/model_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/model_service_client_config.json new file mode 100644 index 00000000000..7734305bc78 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/model_service_client_config.json @@ -0,0 +1,66 @@ +{ + "interfaces": { + "google.cloud.retail.v2alpha.ModelService": { + "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": { + "CreateModel": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "GetModel": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "PauseModel": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ResumeModel": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "DeleteModel": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListModels": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateModel": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "TuneModel": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/model_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/model_service_proto_list.json new file mode 100644 index 00000000000..b794e38509a --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/model_service_proto_list.json @@ -0,0 +1,24 @@ +[ + "../../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/merchant_center_account_link.proto", + "../../protos/google/cloud/retail/v2alpha/merchant_center_account_link_service.proto", + "../../protos/google/cloud/retail/v2alpha/model.proto", + "../../protos/google/cloud/retail/v2alpha/model_service.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/google-cloud-retail/v2alpha/src/v2alpha/prediction_service_client.ts b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/prediction_service_client.ts new file mode 100644 index 00000000000..21164b7a844 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/prediction_service_client.ts @@ -0,0 +1,1291 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LocationsClient, LocationProtos} 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}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + 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/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new PredictionServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof 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); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + 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}' + ), + merchantCenterAccountLinkPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/merchantCenterAccountLinks/{merchant_center_account_link}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + 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. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',additional_bindings: [{get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/places/*/operations/*}',},{get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2alpha/{name=projects/*/locations/*/operations/*}',},{get: '/v2alpha/{name=projects/*/operations/*}',}], + },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2alpha/{name=projects/*/locations/*/catalogs/*}/operations',additional_bindings: [{get: '/v2alpha/{name=projects/*/locations/*}/operations',},{get: '/v2alpha/{name=projects/*}/operations',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + + this.descriptors.longrunning = { + }; + + // 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 = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.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._opts.fallback + ); + + 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: + * `{placement=projects/* /locations/global/catalogs/default_catalog/servingConfigs/*}` + * or + * `{placement=projects/* /locations/global/catalogs/default_catalog/placements/*}`. + * We recommend using the `servingConfigs` resource. `placements` is a legacy + * resource. + * The ID of the Recommendations AI serving config or placement. + * Before you can request predictions from your model, you must create at + * least one serving config or placement for it. For more information, see + * [Manage serving configs] + * (https://cloud.google.com/retail/docs/manage-configs). + * + * The full list of available serving configs can be seen at + * https://console.cloud.google.com/ai/retail/catalogs/default_catalog/configs + * @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. + * + * Don't set + * {@link google.cloud.retail.v2alpha.UserEvent.visitor_id|UserEvent.visitor_id} or + * {@link google.cloud.retail.v2alpha.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.v2alpha.UserEvent.visitor_id|UserEvent.visitor_id} to + * a random unique ID and leave + * {@link google.cloud.retail.v2alpha.UserInfo.user_id|UserInfo.user_id} unset. + * @param {number} request.pageSize + * Maximum number of results to return. 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 + * This field is not used; leave it unset. + * @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 *no* + * results. If instead you want empty result sets to return generic + * (unfiltered) popular products, set `strictFiltering` to False in + * `PredictRequest.params`. Note that the API will never return items with + * storageStatus of "EXPIRED" or "DELETED" regardless of filter choices. + * + * If `filterSyntaxV2` is set to true under the `params` field, then + * attribute-based expressions are expected instead of the above described + * tag-based syntax. Examples: + * + * * (colors: ANY("Red", "Blue")) AND NOT (categories: ANY("Phones")) + * * (availability: ANY("IN_STOCK")) AND + * (colors: ANY("Red") OR categories: ANY("Phones")) + * + * For more information, see + * [Filter recommendations](https://cloud.google.com/retail/docs/filter-recs). + * @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 a 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. + * * `filterSyntaxV2`: Boolean. False by default. If set to true, the `filter` + * field is interpreteted according to the new, attribute-based syntax. + * @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 {@link google.cloud.retail.v2alpha.PredictResponse | 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'placement': request.placement ?? '', + }); + this.initialize(); + return this.innerApiCalls.predict(request, options, callback); + } + +/** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + +/** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + +/** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified 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 merchantCenterAccountLink resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} merchant_center_account_link + * @returns {string} Resource name string. + */ + merchantCenterAccountLinkPath(project:string,location:string,catalog:string,merchantCenterAccountLink:string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + merchant_center_account_link: merchantCenterAccountLink, + }); + } + + /** + * Parse the project from MerchantCenterAccountLink resource. + * + * @param {string} merchantCenterAccountLinkName + * A fully-qualified path representing MerchantCenterAccountLink resource. + * @returns {string} A string representing the project. + */ + matchProjectFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).project; + } + + /** + * Parse the location from MerchantCenterAccountLink resource. + * + * @param {string} merchantCenterAccountLinkName + * A fully-qualified path representing MerchantCenterAccountLink resource. + * @returns {string} A string representing the location. + */ + matchLocationFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).location; + } + + /** + * Parse the catalog from MerchantCenterAccountLink resource. + * + * @param {string} merchantCenterAccountLinkName + * A fully-qualified path representing MerchantCenterAccountLink resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).catalog; + } + + /** + * Parse the merchant_center_account_link from MerchantCenterAccountLink resource. + * + * @param {string} merchantCenterAccountLinkName + * A fully-qualified path representing MerchantCenterAccountLink resource. + * @returns {string} A string representing the merchant_center_account_link. + */ + matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).merchant_center_account_link; + } + + /** + * Return a fully-qualified model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project:string,location:string,catalog:string,model:string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * 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(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/prediction_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/prediction_service_client_config.json new file mode 100644 index 00000000000..ed48fe50101 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2alpha/src/v2alpha/prediction_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/prediction_service_proto_list.json new file mode 100644 index 00000000000..b794e38509a --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/prediction_service_proto_list.json @@ -0,0 +1,24 @@ +[ + "../../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/merchant_center_account_link.proto", + "../../protos/google/cloud/retail/v2alpha/merchant_center_account_link_service.proto", + "../../protos/google/cloud/retail/v2alpha/model.proto", + "../../protos/google/cloud/retail/v2alpha/model_service.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/google-cloud-retail/v2alpha/src/v2alpha/product_service_client.ts b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/product_service_client.ts new file mode 100644 index 00000000000..255919269a0 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/product_service_client.ts @@ -0,0 +1,3133 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/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'; +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}; + locationsClient: LocationsClient; + 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/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new ProductServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof 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); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + 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}' + ), + merchantCenterAccountLinkPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/merchantCenterAccountLinks/{merchant_center_account_link}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + 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. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',additional_bindings: [{get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/places/*/operations/*}',},{get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2alpha/{name=projects/*/locations/*/operations/*}',},{get: '/v2alpha/{name=projects/*/operations/*}',}], + },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2alpha/{name=projects/*/locations/*/catalogs/*}/operations',additional_bindings: [{get: '/v2alpha/{name=projects/*/locations/*}/operations',},{get: '/v2alpha/{name=projects/*}/operations',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).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 = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.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._opts.fallback + ); + + 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 {@link google.cloud.retail.v2alpha.Product | 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' + ] = this._gaxModule.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 {@link google.cloud.retail.v2alpha.Product | 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' + ] = this._gaxModule.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. + * + * 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.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 {@link google.cloud.retail.v2alpha.Product | 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' + ] = this._gaxModule.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 {boolean} request.force + * This value only applies to the case when the target product is of type + * PRIMARY. + * When deleting a product of VARIANT/COLLECTION type, this value + * will be ignored. + * When set to true, the subsequent variant products will be + * deleted. + * When set to false, if the primary product has active variant products, an + * error will be 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 {@link google.protobuf.Empty | 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' + ] = this._gaxModule.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|ProductService.GetProduct} + * or + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.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' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.purgeProducts(request, options, callback); + } +/** + * Check the status of the long running operation returned by `purgeProducts()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2alpha/product_service.purge_products.js + * region_tag:retail_v2alpha_generated_ProductService_PurgeProducts_async + */ + async checkPurgeProductsProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.purgeProducts, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Bulk import of multiple {@link google.cloud.retail.v2alpha.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.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, all fields are updated. + * @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 + * Full Pub/Sub topic name for receiving notification. If this field is set, + * when the import is finished, a notification is sent to + * specified Pub/Sub topic. The message data is 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.v2alpha.ImportProductsRequest.parent|ImportProductsRequest.parent}. + * Make sure that `service-@gcp-sa-retail.iam.gserviceaccount.com` has the + * `pubsub.topics.publish` IAM permission on the topic. + * @param {boolean} request.skipDefaultBranchProtection + * If true, this performs the FULL import even if it would delete a large + * proportion of the products in the default branch, which could potentially + * cause outages if you have live predict/search traffic. + * + * 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' + ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.importProducts, this._gaxModule.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 is 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|ProductService.GetProduct} + * or + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts}. + * + * When inventory is updated with + * {@link google.cloud.retail.v2alpha.ProductService.CreateProduct|ProductService.CreateProduct} + * and + * {@link google.cloud.retail.v2alpha.ProductService.UpdateProduct|ProductService.UpdateProduct}, + * the specified inventory field value(s) overwrite any existing value(s) + * while ignoring the last update time for this field. Furthermore, the last + * update times for the specified inventory fields are overwritten by the + * times of the + * {@link google.cloud.retail.v2alpha.ProductService.CreateProduct|ProductService.CreateProduct} + * or + * {@link google.cloud.retail.v2alpha.ProductService.UpdateProduct|ProductService.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 is used. + * + * If no inventory fields are set in + * {@link google.cloud.retail.v2alpha.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask}, + * then any existing inventory information is preserved. + * + * Pre-existing inventory information can only be updated with + * {@link google.cloud.retail.v2alpha.ProductService.SetInventory|ProductService.SetInventory}, + * {@link google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlaces|ProductService.AddFulfillmentPlaces}, + * and + * {@link google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces|ProductService.RemoveFulfillmentPlaces}. + * + * The returned {@link google.longrunning.Operation|Operation}s is obsolete after + * one day, and the {@link google.longrunning.Operations.GetOperation|GetOperation} + * API returns `NOT_FOUND` afterwards. + * + * If conflicting updates are issued, the + * {@link google.longrunning.Operation|Operation}s associated with the stale + * updates are not marked as {@link google.longrunning.Operation.done|done} until + * they are obsolete. + * + * @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 google.cloud.retail.v2alpha.Product.name|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 google.cloud.retail.v2alpha.Product.fulfillment_info|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 google.cloud.retail.v2alpha.Product.fulfillment_info|SetInventoryRequest.inventory.fulfillment_info} + * * Checks that only the desired fulfillment info types have empty + * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|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 google.cloud.retail.v2alpha.ProductService.UpdateProduct|ProductService.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' + ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.setInventory, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * It is recommended to use the + * {@link google.cloud.retail.v2alpha.ProductService.AddLocalInventories|ProductService.AddLocalInventories} + * method instead of + * {@link google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlaces|ProductService.AddFulfillmentPlaces}. + * {@link google.cloud.retail.v2alpha.ProductService.AddLocalInventories|ProductService.AddLocalInventories} + * achieves the same results but provides more fine-grained control over + * ingesting local inventory data. + * + * 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|ProductService.GetProduct} + * or + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts}. + * + * The returned {@link google.longrunning.Operation|Operation}s will be obsolete + * after 1 day, and {@link google.longrunning.Operations.GetOperation|GetOperation} + * API will return NOT_FOUND afterwards. + * + * If conflicting updates are issued, the + * {@link google.longrunning.Operation|Operation}s associated with the stale + * updates will not be marked as {@link google.longrunning.Operation.done|done} + * until being obsolete. + * + * @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 google.cloud.retail.v2alpha.FulfillmentInfo.type|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' + ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.addFulfillmentPlaces, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * It is recommended to use the + * {@link google.cloud.retail.v2alpha.ProductService.RemoveLocalInventories|ProductService.RemoveLocalInventories} + * method instead of + * {@link google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces|ProductService.RemoveFulfillmentPlaces}. + * {@link google.cloud.retail.v2alpha.ProductService.RemoveLocalInventories|ProductService.RemoveLocalInventories} + * achieves the same results but provides more fine-grained control over + * ingesting local inventory data. + * + * 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|ProductService.GetProduct} + * or + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts}. + * + * The returned {@link google.longrunning.Operation|Operation}s will be obsolete + * after 1 day, and {@link google.longrunning.Operations.GetOperation|GetOperation} + * API will return NOT_FOUND afterwards. + * + * If conflicting updates are issued, the + * {@link google.longrunning.Operation|Operation}s associated with the stale + * updates will not be marked as {@link google.longrunning.Operation.done|done} + * until being obsolete. + * + * @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 google.cloud.retail.v2alpha.FulfillmentInfo.type|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' + ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.removeFulfillmentPlaces, this._gaxModule.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|ProductService.GetProduct} + * or + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts}. + * + * Local inventory information can only be modified using this method. + * {@link google.cloud.retail.v2alpha.ProductService.CreateProduct|ProductService.CreateProduct} + * and + * {@link google.cloud.retail.v2alpha.ProductService.UpdateProduct|ProductService.UpdateProduct} + * has no effect on local inventories. + * + * The returned {@link google.longrunning.Operation|Operation}s will be obsolete + * after 1 day, and {@link google.longrunning.Operations.GetOperation|GetOperation} + * API will return NOT_FOUND afterwards. + * + * If conflicting updates are issued, the + * {@link google.longrunning.Operation|Operation}s associated with the stale + * updates will not be marked as {@link google.longrunning.Operation.done|done} + * until being obsolete. + * + * @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' + ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.addLocalInventories, this._gaxModule.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|ProductService.GetProduct} + * or + * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts}. + * + * Local inventory information can only be removed using this method. + * {@link google.cloud.retail.v2alpha.ProductService.CreateProduct|ProductService.CreateProduct} + * and + * {@link google.cloud.retail.v2alpha.ProductService.UpdateProduct|ProductService.UpdateProduct} + * has no effect on local inventories. + * + * The returned {@link google.longrunning.Operation|Operation}s will be obsolete + * after 1 day, and {@link google.longrunning.Operations.GetOperation|GetOperation} + * API will return NOT_FOUND afterwards. + * + * If conflicting updates are issued, the + * {@link google.longrunning.Operation|Operation}s associated with the stale + * updates will not be marked as {@link google.longrunning.Operation.done|done} + * until being obsolete. + * + * @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' + ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.removeLocalInventories, this._gaxModule.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 {@link google.cloud.retail.v2alpha.Product | 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listProducts(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The 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 {@link google.cloud.retail.v2alpha.Product | 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listProducts']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProducts.createStream( + this.innerApiCalls.listProducts as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProducts`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The 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 + * {@link google.cloud.retail.v2alpha.Product | 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listProducts']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProducts.asyncIterate( + this.innerApiCalls['listProducts'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } +/** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + +/** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + +/** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified 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 merchantCenterAccountLink resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} merchant_center_account_link + * @returns {string} Resource name string. + */ + merchantCenterAccountLinkPath(project:string,location:string,catalog:string,merchantCenterAccountLink:string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + merchant_center_account_link: merchantCenterAccountLink, + }); + } + + /** + * Parse the project from MerchantCenterAccountLink resource. + * + * @param {string} merchantCenterAccountLinkName + * A fully-qualified path representing MerchantCenterAccountLink resource. + * @returns {string} A string representing the project. + */ + matchProjectFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).project; + } + + /** + * Parse the location from MerchantCenterAccountLink resource. + * + * @param {string} merchantCenterAccountLinkName + * A fully-qualified path representing MerchantCenterAccountLink resource. + * @returns {string} A string representing the location. + */ + matchLocationFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).location; + } + + /** + * Parse the catalog from MerchantCenterAccountLink resource. + * + * @param {string} merchantCenterAccountLinkName + * A fully-qualified path representing MerchantCenterAccountLink resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).catalog; + } + + /** + * Parse the merchant_center_account_link from MerchantCenterAccountLink resource. + * + * @param {string} merchantCenterAccountLinkName + * A fully-qualified path representing MerchantCenterAccountLink resource. + * @returns {string} A string representing the merchant_center_account_link. + */ + matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).merchant_center_account_link; + } + + /** + * Return a fully-qualified model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project:string,location:string,catalog:string,model:string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * 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.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/product_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/product_service_client_config.json new file mode 100644 index 00000000000..416ef1ec1c3 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2alpha/src/v2alpha/product_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/product_service_proto_list.json new file mode 100644 index 00000000000..b794e38509a --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/product_service_proto_list.json @@ -0,0 +1,24 @@ +[ + "../../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/merchant_center_account_link.proto", + "../../protos/google/cloud/retail/v2alpha/merchant_center_account_link_service.proto", + "../../protos/google/cloud/retail/v2alpha/model.proto", + "../../protos/google/cloud/retail/v2alpha/model_service.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/google-cloud-retail/v2alpha/src/v2alpha/search_service_client.ts b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/search_service_client.ts new file mode 100644 index 00000000000..bcc89dff5b7 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/search_service_client.ts @@ -0,0 +1,2165 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/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. + * 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}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + 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/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new SearchServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof 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); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + 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}' + ), + experimentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/experiments/{experiment}' + ), + merchantCenterAccountLinkPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/merchantCenterAccountLinks/{merchant_center_account_link}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + 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') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',additional_bindings: [{get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/places/*/operations/*}',},{get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2alpha/{name=projects/*/locations/*/operations/*}',},{get: '/v2alpha/{name=projects/*/operations/*}',}], + },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2alpha/{name=projects/*/locations/*/catalogs/*}/operations',additional_bindings: [{get: '/v2alpha/{name=projects/*/locations/*}/operations',},{get: '/v2alpha/{name=projects/*}/operations',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + + this.descriptors.longrunning = { + }; + + // 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 = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.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._opts.fallback + ); + + 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. + * 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 Retail Search serving config, such as + * `projects/* /locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` + * or the name of the legacy placement resource, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. + * This field is used to identify the serving config 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.v2alpha.SearchRequest.filter|filter} and + * {@link google.cloud.retail.v2alpha.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.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 200 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 + * {@link google.cloud.retail.v2alpha.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.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 google.cloud.retail.v2alpha.LocalInventory.attributes|Product.local_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. Must be set 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, 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. + * + * Notice that if both + * {@link google.cloud.retail.v2alpha.ServingConfig.personalization_spec|ServingConfig.personalization_spec} + * and + * {@link google.cloud.retail.v2alpha.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * are set. + * {@link google.cloud.retail.v2alpha.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * will override + * {@link google.cloud.retail.v2alpha.ServingConfig.personalization_spec|ServingConfig.personalization_spec}. + * @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.v2alpha.SearchRequest.SpellCorrectionSpec} request.spellCorrectionSpec + * The spell correction specification that specifies the mode under + * which spell correction will take effect. + * @param {string} request.entity + * The entity for customers that may run multiple different entities, domains, + * sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, + * `google.com`, `youtube.com`, etc. + * If this is set, it should be exactly matched with + * {@link google.cloud.retail.v2alpha.UserEvent.entity|UserEvent.entity} to get + * search results boosted by entity. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 {@link google.cloud.retail.v2alpha.SearchResponse.SearchResult | 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' + ] = this._gaxModule.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 Retail Search serving config, such as + * `projects/* /locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` + * or the name of the legacy placement resource, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. + * This field is used to identify the serving config 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.v2alpha.SearchRequest.filter|filter} and + * {@link google.cloud.retail.v2alpha.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.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 200 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 + * {@link google.cloud.retail.v2alpha.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.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 google.cloud.retail.v2alpha.LocalInventory.attributes|Product.local_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. Must be set 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, 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. + * + * Notice that if both + * {@link google.cloud.retail.v2alpha.ServingConfig.personalization_spec|ServingConfig.personalization_spec} + * and + * {@link google.cloud.retail.v2alpha.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * are set. + * {@link google.cloud.retail.v2alpha.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * will override + * {@link google.cloud.retail.v2alpha.ServingConfig.personalization_spec|ServingConfig.personalization_spec}. + * @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.v2alpha.SearchRequest.SpellCorrectionSpec} request.spellCorrectionSpec + * The spell correction specification that specifies the mode under + * which spell correction will take effect. + * @param {string} request.entity + * The entity for customers that may run multiple different entities, domains, + * sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, + * `google.com`, `youtube.com`, etc. + * If this is set, it should be exactly matched with + * {@link google.cloud.retail.v2alpha.UserEvent.entity|UserEvent.entity} to get + * search results boosted by entity. + * @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 {@link google.cloud.retail.v2alpha.SearchResponse.SearchResult | 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' + ] = this._gaxModule.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 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 Retail Search serving config, such as + * `projects/* /locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` + * or the name of the legacy placement resource, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. + * This field is used to identify the serving config 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.v2alpha.SearchRequest.filter|filter} and + * {@link google.cloud.retail.v2alpha.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.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 200 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 + * {@link google.cloud.retail.v2alpha.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.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 google.cloud.retail.v2alpha.LocalInventory.attributes|Product.local_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. Must be set 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, 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. + * + * Notice that if both + * {@link google.cloud.retail.v2alpha.ServingConfig.personalization_spec|ServingConfig.personalization_spec} + * and + * {@link google.cloud.retail.v2alpha.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * are set. + * {@link google.cloud.retail.v2alpha.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * will override + * {@link google.cloud.retail.v2alpha.ServingConfig.personalization_spec|ServingConfig.personalization_spec}. + * @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.v2alpha.SearchRequest.SpellCorrectionSpec} request.spellCorrectionSpec + * The spell correction specification that specifies the mode under + * which spell correction will take effect. + * @param {string} request.entity + * The entity for customers that may run multiple different entities, domains, + * sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, + * `google.com`, `youtube.com`, etc. + * If this is set, it should be exactly matched with + * {@link google.cloud.retail.v2alpha.UserEvent.entity|UserEvent.entity} to get + * search results boosted by entity. + * @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 + * {@link google.cloud.retail.v2alpha.SearchResponse.SearchResult | 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' + ] = this._gaxModule.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 {}, + callSettings + ) as AsyncIterable; + } +/** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + +/** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + +/** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified 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 experiment resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} experiment + * @returns {string} Resource name string. + */ + experimentPath(project:string,location:string,catalog:string,experiment:string) { + return this.pathTemplates.experimentPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + experiment: experiment, + }); + } + + /** + * Parse the project from Experiment resource. + * + * @param {string} experimentName + * A fully-qualified path representing Experiment resource. + * @returns {string} A string representing the project. + */ + matchProjectFromExperimentName(experimentName: string) { + return this.pathTemplates.experimentPathTemplate.match(experimentName).project; + } + + /** + * Parse the location from Experiment resource. + * + * @param {string} experimentName + * A fully-qualified path representing Experiment resource. + * @returns {string} A string representing the location. + */ + matchLocationFromExperimentName(experimentName: string) { + return this.pathTemplates.experimentPathTemplate.match(experimentName).location; + } + + /** + * Parse the catalog from Experiment resource. + * + * @param {string} experimentName + * A fully-qualified path representing Experiment resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromExperimentName(experimentName: string) { + return this.pathTemplates.experimentPathTemplate.match(experimentName).catalog; + } + + /** + * Parse the experiment from Experiment resource. + * + * @param {string} experimentName + * A fully-qualified path representing Experiment resource. + * @returns {string} A string representing the experiment. + */ + matchExperimentFromExperimentName(experimentName: string) { + return this.pathTemplates.experimentPathTemplate.match(experimentName).experiment; + } + + /** + * Return a fully-qualified merchantCenterAccountLink resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} merchant_center_account_link + * @returns {string} Resource name string. + */ + merchantCenterAccountLinkPath(project:string,location:string,catalog:string,merchantCenterAccountLink:string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + merchant_center_account_link: merchantCenterAccountLink, + }); + } + + /** + * Parse the project from MerchantCenterAccountLink resource. + * + * @param {string} merchantCenterAccountLinkName + * A fully-qualified path representing MerchantCenterAccountLink resource. + * @returns {string} A string representing the project. + */ + matchProjectFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).project; + } + + /** + * Parse the location from MerchantCenterAccountLink resource. + * + * @param {string} merchantCenterAccountLinkName + * A fully-qualified path representing MerchantCenterAccountLink resource. + * @returns {string} A string representing the location. + */ + matchLocationFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).location; + } + + /** + * Parse the catalog from MerchantCenterAccountLink resource. + * + * @param {string} merchantCenterAccountLinkName + * A fully-qualified path representing MerchantCenterAccountLink resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).catalog; + } + + /** + * Parse the merchant_center_account_link from MerchantCenterAccountLink resource. + * + * @param {string} merchantCenterAccountLinkName + * A fully-qualified path representing MerchantCenterAccountLink resource. + * @returns {string} A string representing the merchant_center_account_link. + */ + matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).merchant_center_account_link; + } + + /** + * Return a fully-qualified model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project:string,location:string,catalog:string,model:string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * 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(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/search_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/search_service_client_config.json new file mode 100644 index 00000000000..71a5a478c8c --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2alpha/src/v2alpha/search_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/search_service_proto_list.json new file mode 100644 index 00000000000..b794e38509a --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/search_service_proto_list.json @@ -0,0 +1,24 @@ +[ + "../../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/merchant_center_account_link.proto", + "../../protos/google/cloud/retail/v2alpha/merchant_center_account_link_service.proto", + "../../protos/google/cloud/retail/v2alpha/model.proto", + "../../protos/google/cloud/retail/v2alpha/model_service.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/google-cloud-retail/v2alpha/src/v2alpha/serving_config_service_client.ts b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/serving_config_service_client.ts new file mode 100644 index 00000000000..444c27ebeea --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/serving_config_service_client.ts @@ -0,0 +1,1759 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/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}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + 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/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new ServingConfigServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof 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); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + 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}' + ), + merchantCenterAccountLinkPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/merchantCenterAccountLinks/{merchant_center_account_link}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + 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') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',additional_bindings: [{get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/places/*/operations/*}',},{get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2alpha/{name=projects/*/locations/*/operations/*}',},{get: '/v2alpha/{name=projects/*/operations/*}',}], + },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2alpha/{name=projects/*/locations/*/catalogs/*}/operations',additional_bindings: [{get: '/v2alpha/{name=projects/*/locations/*}/operations',},{get: '/v2alpha/{name=projects/*}/operations',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + + this.descriptors.longrunning = { + }; + + // 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 = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.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._opts.fallback + ); + + 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 {@link google.cloud.retail.v2alpha.ServingConfig | 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' + ] = this._gaxModule.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 {@link google.protobuf.Empty | 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' + ] = this._gaxModule.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 {@link google.cloud.retail.v2alpha.ServingConfig | 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' + ] = this._gaxModule.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 {@link google.cloud.retail.v2alpha.ServingConfig | 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' + ] = this._gaxModule.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 {@link google.cloud.retail.v2alpha.ServingConfig | 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' + ] = this._gaxModule.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 {@link google.cloud.retail.v2alpha.ServingConfig | 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' + ] = this._gaxModule.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 {@link google.cloud.retail.v2alpha.ServingConfig | 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' + ] = this._gaxModule.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 {@link google.cloud.retail.v2alpha.ServingConfig | 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' + ] = this._gaxModule.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 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 + * {@link google.cloud.retail.v2alpha.ServingConfig | 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' + ] = this._gaxModule.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 {}, + callSettings + ) as AsyncIterable; + } +/** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + +/** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + +/** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified 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 merchantCenterAccountLink resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} merchant_center_account_link + * @returns {string} Resource name string. + */ + merchantCenterAccountLinkPath(project:string,location:string,catalog:string,merchantCenterAccountLink:string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + merchant_center_account_link: merchantCenterAccountLink, + }); + } + + /** + * Parse the project from MerchantCenterAccountLink resource. + * + * @param {string} merchantCenterAccountLinkName + * A fully-qualified path representing MerchantCenterAccountLink resource. + * @returns {string} A string representing the project. + */ + matchProjectFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).project; + } + + /** + * Parse the location from MerchantCenterAccountLink resource. + * + * @param {string} merchantCenterAccountLinkName + * A fully-qualified path representing MerchantCenterAccountLink resource. + * @returns {string} A string representing the location. + */ + matchLocationFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).location; + } + + /** + * Parse the catalog from MerchantCenterAccountLink resource. + * + * @param {string} merchantCenterAccountLinkName + * A fully-qualified path representing MerchantCenterAccountLink resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).catalog; + } + + /** + * Parse the merchant_center_account_link from MerchantCenterAccountLink resource. + * + * @param {string} merchantCenterAccountLinkName + * A fully-qualified path representing MerchantCenterAccountLink resource. + * @returns {string} A string representing the merchant_center_account_link. + */ + matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).merchant_center_account_link; + } + + /** + * Return a fully-qualified model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project:string,location:string,catalog:string,model:string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * 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(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/serving_config_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/serving_config_service_client_config.json new file mode 100644 index 00000000000..6489c5db6ef --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2alpha/src/v2alpha/serving_config_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/serving_config_service_proto_list.json new file mode 100644 index 00000000000..b794e38509a --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/serving_config_service_proto_list.json @@ -0,0 +1,24 @@ +[ + "../../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/merchant_center_account_link.proto", + "../../protos/google/cloud/retail/v2alpha/merchant_center_account_link_service.proto", + "../../protos/google/cloud/retail/v2alpha/model.proto", + "../../protos/google/cloud/retail/v2alpha/model_service.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/google-cloud-retail/v2alpha/src/v2alpha/user_event_service_client.ts b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/user_event_service_client.ts new file mode 100644 index 00000000000..d1c38c4d95b --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/user_event_service_client.ts @@ -0,0 +1,1625 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, LocationsClient, LocationProtos} 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'; +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}; + locationsClient: LocationsClient; + 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/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new UserEventServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof 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); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + 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}' + ), + merchantCenterAccountLinkPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/merchantCenterAccountLinks/{merchant_center_account_link}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + 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. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',additional_bindings: [{get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/places/*/operations/*}',},{get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2alpha/{name=projects/*/locations/*/operations/*}',},{get: '/v2alpha/{name=projects/*/operations/*}',}], + },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2alpha/{name=projects/*/locations/*/catalogs/*}/operations',additional_bindings: [{get: '/v2alpha/{name=projects/*/locations/*}/operations',},{get: '/v2alpha/{name=projects/*}/operations',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).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 = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.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._opts.fallback + ); + + 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 {boolean} request.writeAsync + * If set to true, the user event will be written asynchronously after + * validation, and the API will respond without waiting for the write. + * Therefore, silent failures can occur even if the API returns success. In + * case of silent failures, error messages can be found in Stackdriver logs. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.retail.v2alpha.UserEvent | 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' + ] = this._gaxModule.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.prebuiltRule + * The prebuilt rule name that can convert a specific type of raw_json. + * For example: "ga4_bq" rule for the GA4 user event schema. + * @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 {string} request.rawJson + * An arbitrary serialized JSON string that contains necessary information + * that can comprise a user event. When this field is specified, the + * user_event field will be ignored. Note: line-delimited JSON is not + * supported, a single JSON only. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.api.HttpBody | 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' + ] = this._gaxModule.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' + ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.purgeUserEvents, this._gaxModule.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' + ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.importUserEvents, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Starts a user-event rejoin operation with latest product catalog. Events + * are not annotated with detailed product information for products that are + * missing from the catalog when the user event is ingested. These + * events are stored as unjoined events with limited usage on training and + * serving. You can use this method to start a join operation on specified + * events with the latest version of product catalog. You can also use this + * method 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' + ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.rejoinUserEvents, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + +/** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + +/** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified 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 merchantCenterAccountLink resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} merchant_center_account_link + * @returns {string} Resource name string. + */ + merchantCenterAccountLinkPath(project:string,location:string,catalog:string,merchantCenterAccountLink:string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + merchant_center_account_link: merchantCenterAccountLink, + }); + } + + /** + * Parse the project from MerchantCenterAccountLink resource. + * + * @param {string} merchantCenterAccountLinkName + * A fully-qualified path representing MerchantCenterAccountLink resource. + * @returns {string} A string representing the project. + */ + matchProjectFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).project; + } + + /** + * Parse the location from MerchantCenterAccountLink resource. + * + * @param {string} merchantCenterAccountLinkName + * A fully-qualified path representing MerchantCenterAccountLink resource. + * @returns {string} A string representing the location. + */ + matchLocationFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).location; + } + + /** + * Parse the catalog from MerchantCenterAccountLink resource. + * + * @param {string} merchantCenterAccountLinkName + * A fully-qualified path representing MerchantCenterAccountLink resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).catalog; + } + + /** + * Parse the merchant_center_account_link from MerchantCenterAccountLink resource. + * + * @param {string} merchantCenterAccountLinkName + * A fully-qualified path representing MerchantCenterAccountLink resource. + * @returns {string} A string representing the merchant_center_account_link. + */ + matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { + return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).merchant_center_account_link; + } + + /** + * Return a fully-qualified model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project:string,location:string,catalog:string,model:string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * 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.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/user_event_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/user_event_service_client_config.json new file mode 100644 index 00000000000..21dfac2e12b --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2alpha/src/v2alpha/user_event_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/user_event_service_proto_list.json new file mode 100644 index 00000000000..b794e38509a --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/user_event_service_proto_list.json @@ -0,0 +1,24 @@ +[ + "../../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/merchant_center_account_link.proto", + "../../protos/google/cloud/retail/v2alpha/merchant_center_account_link_service.proto", + "../../protos/google/cloud/retail/v2alpha/model.proto", + "../../protos/google/cloud/retail/v2alpha/model_service.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/google-cloud-retail/v2alpha/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-retail/v2alpha/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..54c40c9f65d --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/system-test/fixtures/sample/src/index.js @@ -0,0 +1,36 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 merchantCenterAccountLinkServiceClient = new retail.MerchantCenterAccountLinkServiceClient(); + const modelServiceClient = new retail.ModelServiceClient(); + 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/google-cloud-retail/v2alpha/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-retail/v2alpha/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..5675c1ca814 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,86 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This 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, MerchantCenterAccountLinkServiceClient, ModelServiceClient, 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 doStuffWithMerchantCenterAccountLinkServiceClient(client: MerchantCenterAccountLinkServiceClient) { + client.close(); +} +function doStuffWithModelServiceClient(client: ModelServiceClient) { + 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 merchantCenterAccountLinkServiceClient = new MerchantCenterAccountLinkServiceClient(); + doStuffWithMerchantCenterAccountLinkServiceClient(merchantCenterAccountLinkServiceClient); + // check that the client instance can be created + const modelServiceClient = new ModelServiceClient(); + doStuffWithModelServiceClient(modelServiceClient); + // 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/google-cloud-retail/v2alpha/system-test/install.ts b/owl-bot-staging/google-cloud-retail/v2alpha/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {packNTest} from 'pack-n-play'; +import {readFileSync} from 'fs'; +import {describe, it} from 'mocha'; + +describe('📦 pack-n-play test', () => { + + it('TypeScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'TypeScript user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); + }); + + it('JavaScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'JavaScript user can use the library', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); + }); + +}); diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_catalog_service_v2alpha.ts b/owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_catalog_service_v2alpha.ts new file mode 100644 index 00000000000..08162257c4d --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_catalog_service_v2alpha.ts @@ -0,0 +1,2574 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This 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, operationsProtos, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function 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', () => { + describe('Common methods', () => { + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateCatalogRequest', ['catalog', 'name']); + request.catalog.name = defaultValue1; + const expectedHeaderRequestParams = `catalog.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.updateCatalog as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateCatalog as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateCatalogRequest', ['catalog', 'name']); + request.catalog.name = defaultValue1; + const expectedHeaderRequestParams = `catalog.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.updateCatalog as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateCatalog as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateCatalogRequest', ['catalog', 'name']); + request.catalog.name = defaultValue1; + const expectedHeaderRequestParams = `catalog.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCatalog = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateCatalog(request), expectedError); + const actualRequest = (client.innerApiCalls.updateCatalog as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateCatalog as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateCatalogRequest', ['catalog', 'name']); + request.catalog.name = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.SetDefaultBranchRequest', ['catalog']); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.setDefaultBranch = stubSimpleCall(expectedResponse); + const [response] = await client.setDefaultBranch(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setDefaultBranch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setDefaultBranch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.SetDefaultBranchRequest', ['catalog']); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.setDefaultBranch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setDefaultBranch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.SetDefaultBranchRequest', ['catalog']); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setDefaultBranch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setDefaultBranch(request), expectedError); + const actualRequest = (client.innerApiCalls.setDefaultBranch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setDefaultBranch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.SetDefaultBranchRequest', ['catalog']); + request.catalog = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.GetDefaultBranchRequest', ['catalog']); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getDefaultBranch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDefaultBranch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.GetDefaultBranchRequest', ['catalog']); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getDefaultBranch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDefaultBranch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.GetDefaultBranchRequest', ['catalog']); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getDefaultBranch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getDefaultBranch(request), expectedError); + const actualRequest = (client.innerApiCalls.getDefaultBranch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDefaultBranch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.GetDefaultBranchRequest', ['catalog']); + request.catalog = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.GetCompletionConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getCompletionConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getCompletionConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.GetCompletionConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getCompletionConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getCompletionConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.GetCompletionConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getCompletionConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getCompletionConfig(request), expectedError); + const actualRequest = (client.innerApiCalls.getCompletionConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getCompletionConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.GetCompletionConfigRequest', ['name']); + request.name = defaultValue1; + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateCompletionConfigRequest', ['completionConfig', 'name']); + request.completionConfig.name = defaultValue1; + const expectedHeaderRequestParams = `completion_config.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.updateCompletionConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateCompletionConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateCompletionConfigRequest', ['completionConfig', 'name']); + request.completionConfig.name = defaultValue1; + const expectedHeaderRequestParams = `completion_config.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.updateCompletionConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateCompletionConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateCompletionConfigRequest', ['completionConfig', 'name']); + request.completionConfig.name = defaultValue1; + const expectedHeaderRequestParams = `completion_config.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCompletionConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateCompletionConfig(request), expectedError); + const actualRequest = (client.innerApiCalls.updateCompletionConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateCompletionConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateCompletionConfigRequest', ['completionConfig', 'name']); + request.completionConfig.name = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.GetAttributesConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getAttributesConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getAttributesConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.GetAttributesConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getAttributesConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getAttributesConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.GetAttributesConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getAttributesConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getAttributesConfig(request), expectedError); + const actualRequest = (client.innerApiCalls.getAttributesConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getAttributesConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.GetAttributesConfigRequest', ['name']); + request.name = defaultValue1; + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateAttributesConfigRequest', ['attributesConfig', 'name']); + request.attributesConfig.name = defaultValue1; + const expectedHeaderRequestParams = `attributes_config.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.updateAttributesConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateAttributesConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateAttributesConfigRequest', ['attributesConfig', 'name']); + request.attributesConfig.name = defaultValue1; + const expectedHeaderRequestParams = `attributes_config.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.updateAttributesConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateAttributesConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateAttributesConfigRequest', ['attributesConfig', 'name']); + request.attributesConfig.name = defaultValue1; + const expectedHeaderRequestParams = `attributes_config.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateAttributesConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateAttributesConfig(request), expectedError); + const actualRequest = (client.innerApiCalls.updateAttributesConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateAttributesConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateAttributesConfigRequest', ['attributesConfig', 'name']); + request.attributesConfig.name = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.AddCatalogAttributeRequest', ['attributesConfig']); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.addCatalogAttribute as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addCatalogAttribute as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.AddCatalogAttributeRequest', ['attributesConfig']); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.addCatalogAttribute as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addCatalogAttribute as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.AddCatalogAttributeRequest', ['attributesConfig']); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addCatalogAttribute = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.addCatalogAttribute(request), expectedError); + const actualRequest = (client.innerApiCalls.addCatalogAttribute as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addCatalogAttribute as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.AddCatalogAttributeRequest', ['attributesConfig']); + request.attributesConfig = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest', ['attributesConfig']); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.removeCatalogAttribute as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeCatalogAttribute as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest', ['attributesConfig']); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.removeCatalogAttribute as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeCatalogAttribute as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest', ['attributesConfig']); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeCatalogAttribute = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.removeCatalogAttribute(request), expectedError); + const actualRequest = (client.innerApiCalls.removeCatalogAttribute as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeCatalogAttribute as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest', ['attributesConfig']); + request.attributesConfig = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.removeCatalogAttribute(request), expectedError); + }); + }); + + describe('batchRemoveCatalogAttributes', () => { + it('invokes batchRemoveCatalogAttributes 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.BatchRemoveCatalogAttributesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.BatchRemoveCatalogAttributesRequest', ['attributesConfig']); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.BatchRemoveCatalogAttributesResponse() + ); + client.innerApiCalls.batchRemoveCatalogAttributes = stubSimpleCall(expectedResponse); + const [response] = await client.batchRemoveCatalogAttributes(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.batchRemoveCatalogAttributes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchRemoveCatalogAttributes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes batchRemoveCatalogAttributes 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.BatchRemoveCatalogAttributesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.BatchRemoveCatalogAttributesRequest', ['attributesConfig']); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.BatchRemoveCatalogAttributesResponse() + ); + client.innerApiCalls.batchRemoveCatalogAttributes = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchRemoveCatalogAttributes( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IBatchRemoveCatalogAttributesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.batchRemoveCatalogAttributes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchRemoveCatalogAttributes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes batchRemoveCatalogAttributes 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.BatchRemoveCatalogAttributesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.BatchRemoveCatalogAttributesRequest', ['attributesConfig']); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.batchRemoveCatalogAttributes = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.batchRemoveCatalogAttributes(request), expectedError); + const actualRequest = (client.innerApiCalls.batchRemoveCatalogAttributes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchRemoveCatalogAttributes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes batchRemoveCatalogAttributes 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.BatchRemoveCatalogAttributesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.BatchRemoveCatalogAttributesRequest', ['attributesConfig']); + request.attributesConfig = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.batchRemoveCatalogAttributes(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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest', ['attributesConfig']); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.replaceCatalogAttribute as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.replaceCatalogAttribute as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest', ['attributesConfig']); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.replaceCatalogAttribute as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.replaceCatalogAttribute as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest', ['attributesConfig']); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.replaceCatalogAttribute = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.replaceCatalogAttribute(request), expectedError); + const actualRequest = (client.innerApiCalls.replaceCatalogAttribute as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.replaceCatalogAttribute as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest', ['attributesConfig']); + request.attributesConfig = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ListCatalogsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.listCatalogs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listCatalogs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ListCatalogsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.listCatalogs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listCatalogs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ListCatalogsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listCatalogs = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listCatalogs(request), expectedError); + const actualRequest = (client.innerApiCalls.listCatalogs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listCatalogs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ListCatalogsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listCatalogs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ListCatalogsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listCatalogs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ListCatalogsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ListCatalogsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getLocation without error using callback', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getLocation(request, expectedOptions), expectedError); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.getOperation(request)}, expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('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('merchantCenterAccountLink', () => { + const fakePath = "/rendered/path/merchantCenterAccountLink"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + merchant_center_account_link: "merchantCenterAccountLinkValue", + }; + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.merchantCenterAccountLinkPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.merchantCenterAccountLinkPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('merchantCenterAccountLinkPath', () => { + const result = client.merchantCenterAccountLinkPath("projectValue", "locationValue", "catalogValue", "merchantCenterAccountLinkValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromMerchantCenterAccountLinkName', () => { + const result = client.matchProjectFromMerchantCenterAccountLinkName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromMerchantCenterAccountLinkName', () => { + const result = client.matchLocationFromMerchantCenterAccountLinkName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromMerchantCenterAccountLinkName', () => { + const result = client.matchCatalogFromMerchantCenterAccountLinkName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName', () => { + const result = client.matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName(fakePath); + assert.strictEqual(result, "merchantCenterAccountLinkValue"); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('model', () => { + const fakePath = "/rendered/path/model"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + model: "modelValue", + }; + const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.modelPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, "modelValue"); + assert((client.pathTemplates.modelPathTemplate.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/google-cloud-retail/v2alpha/test/gapic_completion_service_v2alpha.ts b/owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_completion_service_v2alpha.ts new file mode 100644 index 00000000000..0c394879563 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_completion_service_v2alpha.ts @@ -0,0 +1,1288 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This 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, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function 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.CompletionServiceClient', () => { + describe('Common methods', () => { + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.CompleteQueryRequest', ['catalog']); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.CompleteQueryRequest', ['catalog']); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.CompleteQueryRequest', ['catalog']); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.completeQuery = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.completeQuery(request), expectedError); + const actualRequest = (client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.CompleteQueryRequest', ['catalog']); + request.catalog = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ImportCompletionDataRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.importCompletionData as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importCompletionData as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ImportCompletionDataRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.importCompletionData as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importCompletionData as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ImportCompletionDataRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importCompletionData = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importCompletionData(request), expectedError); + const actualRequest = (client.innerApiCalls.importCompletionData as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importCompletionData as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ImportCompletionDataRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importCompletionData = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importCompletionData(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.importCompletionData as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importCompletionData as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getLocation without error using callback', async () => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getLocation(request, expectedOptions), expectedError); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.getOperation(request)}, expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('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('merchantCenterAccountLink', () => { + const fakePath = "/rendered/path/merchantCenterAccountLink"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + merchant_center_account_link: "merchantCenterAccountLinkValue", + }; + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.merchantCenterAccountLinkPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.merchantCenterAccountLinkPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('merchantCenterAccountLinkPath', () => { + const result = client.merchantCenterAccountLinkPath("projectValue", "locationValue", "catalogValue", "merchantCenterAccountLinkValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromMerchantCenterAccountLinkName', () => { + const result = client.matchProjectFromMerchantCenterAccountLinkName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromMerchantCenterAccountLinkName', () => { + const result = client.matchLocationFromMerchantCenterAccountLinkName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromMerchantCenterAccountLinkName', () => { + const result = client.matchCatalogFromMerchantCenterAccountLinkName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName', () => { + const result = client.matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName(fakePath); + assert.strictEqual(result, "merchantCenterAccountLinkValue"); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('model', () => { + const fakePath = "/rendered/path/model"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + model: "modelValue", + }; + const client = new completionserviceModule.v2alpha.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.modelPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, "modelValue"); + assert((client.pathTemplates.modelPathTemplate.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/google-cloud-retail/v2alpha/test/gapic_control_service_v2alpha.ts b/owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_control_service_v2alpha.ts new file mode 100644 index 00000000000..516086cb2d4 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_control_service_v2alpha.ts @@ -0,0 +1,1718 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This 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, operationsProtos, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function 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', () => { + describe('Common methods', () => { + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.CreateControlRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.createControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.CreateControlRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.createControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.CreateControlRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createControl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createControl(request), expectedError); + const actualRequest = (client.innerApiCalls.createControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.CreateControlRequest', ['parent']); + request.parent = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.DeleteControlRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteControl = stubSimpleCall(expectedResponse); + const [response] = await client.deleteControl(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.DeleteControlRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.deleteControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.DeleteControlRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteControl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteControl(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.DeleteControlRequest', ['name']); + request.name = defaultValue1; + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateControlRequest', ['control', 'name']); + request.control.name = defaultValue1; + const expectedHeaderRequestParams = `control.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.updateControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateControlRequest', ['control', 'name']); + request.control.name = defaultValue1; + const expectedHeaderRequestParams = `control.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.updateControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateControlRequest', ['control', 'name']); + request.control.name = defaultValue1; + const expectedHeaderRequestParams = `control.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateControl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateControl(request), expectedError); + const actualRequest = (client.innerApiCalls.updateControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateControlRequest', ['control', 'name']); + request.control.name = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.GetControlRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.GetControlRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.GetControlRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getControl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getControl(request), expectedError); + const actualRequest = (client.innerApiCalls.getControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.GetControlRequest', ['name']); + request.name = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ListControlsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.listControls as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listControls as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ListControlsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.listControls as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listControls as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ListControlsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listControls = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listControls(request), expectedError); + const actualRequest = (client.innerApiCalls.listControls as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listControls as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ListControlsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listControls.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ListControlsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listControls.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ListControlsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listControls.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ListControlsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listControls.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getLocation without error using callback', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getLocation(request, expectedOptions), expectedError); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.getOperation(request)}, expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('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('merchantCenterAccountLink', () => { + const fakePath = "/rendered/path/merchantCenterAccountLink"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + merchant_center_account_link: "merchantCenterAccountLinkValue", + }; + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.merchantCenterAccountLinkPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.merchantCenterAccountLinkPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('merchantCenterAccountLinkPath', () => { + const result = client.merchantCenterAccountLinkPath("projectValue", "locationValue", "catalogValue", "merchantCenterAccountLinkValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromMerchantCenterAccountLinkName', () => { + const result = client.matchProjectFromMerchantCenterAccountLinkName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromMerchantCenterAccountLinkName', () => { + const result = client.matchLocationFromMerchantCenterAccountLinkName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromMerchantCenterAccountLinkName', () => { + const result = client.matchCatalogFromMerchantCenterAccountLinkName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName', () => { + const result = client.matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName(fakePath); + assert.strictEqual(result, "merchantCenterAccountLinkValue"); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('model', () => { + const fakePath = "/rendered/path/model"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + model: "modelValue", + }; + const client = new controlserviceModule.v2alpha.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.modelPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, "modelValue"); + assert((client.pathTemplates.modelPathTemplate.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/google-cloud-retail/v2alpha/test/gapic_merchant_center_account_link_service_v2alpha.ts b/owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_merchant_center_account_link_service_v2alpha.ts new file mode 100644 index 00000000000..fbfe6d23560 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_merchant_center_account_link_service_v2alpha.ts @@ -0,0 +1,1396 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This 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 merchantcenteraccountlinkserviceModule from '../src'; + +import {protobuf, LROperation, operationsProtos, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function 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.MerchantCenterAccountLinkServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.merchantCenterAccountLinkServiceStub, undefined); + await client.initialize(); + assert(client.merchantCenterAccountLinkServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.merchantCenterAccountLinkServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.merchantCenterAccountLinkServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ + 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 merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ + 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('listMerchantCenterAccountLinks', () => { + it('invokes listMerchantCenterAccountLinks without error', async () => { + const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListMerchantCenterAccountLinksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ListMerchantCenterAccountLinksRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListMerchantCenterAccountLinksResponse() + ); + client.innerApiCalls.listMerchantCenterAccountLinks = stubSimpleCall(expectedResponse); + const [response] = await client.listMerchantCenterAccountLinks(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listMerchantCenterAccountLinks as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listMerchantCenterAccountLinks as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listMerchantCenterAccountLinks without error using callback', async () => { + const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListMerchantCenterAccountLinksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ListMerchantCenterAccountLinksRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListMerchantCenterAccountLinksResponse() + ); + client.innerApiCalls.listMerchantCenterAccountLinks = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listMerchantCenterAccountLinks( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IListMerchantCenterAccountLinksResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listMerchantCenterAccountLinks as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listMerchantCenterAccountLinks as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listMerchantCenterAccountLinks with error', async () => { + const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListMerchantCenterAccountLinksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ListMerchantCenterAccountLinksRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listMerchantCenterAccountLinks = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listMerchantCenterAccountLinks(request), expectedError); + const actualRequest = (client.innerApiCalls.listMerchantCenterAccountLinks as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listMerchantCenterAccountLinks as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listMerchantCenterAccountLinks with closed client', async () => { + const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListMerchantCenterAccountLinksRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ListMerchantCenterAccountLinksRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.listMerchantCenterAccountLinks(request), expectedError); + }); + }); + + describe('deleteMerchantCenterAccountLink', () => { + it('invokes deleteMerchantCenterAccountLink without error', async () => { + const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.DeleteMerchantCenterAccountLinkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.DeleteMerchantCenterAccountLinkRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteMerchantCenterAccountLink = stubSimpleCall(expectedResponse); + const [response] = await client.deleteMerchantCenterAccountLink(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteMerchantCenterAccountLink as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteMerchantCenterAccountLink as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteMerchantCenterAccountLink without error using callback', async () => { + const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.DeleteMerchantCenterAccountLinkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.DeleteMerchantCenterAccountLinkRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteMerchantCenterAccountLink = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteMerchantCenterAccountLink( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteMerchantCenterAccountLink as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteMerchantCenterAccountLink as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteMerchantCenterAccountLink with error', async () => { + const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.DeleteMerchantCenterAccountLinkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.DeleteMerchantCenterAccountLinkRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteMerchantCenterAccountLink = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteMerchantCenterAccountLink(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteMerchantCenterAccountLink as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteMerchantCenterAccountLink as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteMerchantCenterAccountLink with closed client', async () => { + const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.DeleteMerchantCenterAccountLinkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.DeleteMerchantCenterAccountLinkRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteMerchantCenterAccountLink(request), expectedError); + }); + }); + + describe('createMerchantCenterAccountLink', () => { + it('invokes createMerchantCenterAccountLink without error', async () => { + const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.CreateMerchantCenterAccountLinkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.CreateMerchantCenterAccountLinkRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createMerchantCenterAccountLink = stubLongRunningCall(expectedResponse); + const [operation] = await client.createMerchantCenterAccountLink(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createMerchantCenterAccountLink as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createMerchantCenterAccountLink as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createMerchantCenterAccountLink without error using callback', async () => { + const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.CreateMerchantCenterAccountLinkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.CreateMerchantCenterAccountLinkRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createMerchantCenterAccountLink = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createMerchantCenterAccountLink( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createMerchantCenterAccountLink as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createMerchantCenterAccountLink as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createMerchantCenterAccountLink with call error', async () => { + const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.CreateMerchantCenterAccountLinkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.CreateMerchantCenterAccountLinkRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createMerchantCenterAccountLink = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createMerchantCenterAccountLink(request), expectedError); + const actualRequest = (client.innerApiCalls.createMerchantCenterAccountLink as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createMerchantCenterAccountLink as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createMerchantCenterAccountLink with LRO error', async () => { + const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.CreateMerchantCenterAccountLinkRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.CreateMerchantCenterAccountLinkRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createMerchantCenterAccountLink = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createMerchantCenterAccountLink(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.createMerchantCenterAccountLink as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createMerchantCenterAccountLink as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateMerchantCenterAccountLinkProgress without error', async () => { + const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateMerchantCenterAccountLinkProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateMerchantCenterAccountLinkProgress with error', async () => { + const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCreateMerchantCenterAccountLinkProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getLocation without error using callback', async () => { + const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getLocation(request, expectedOptions), expectedError); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.getOperation(request)}, expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('attributesConfig', () => { + const fakePath = "/rendered/path/attributesConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ + 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 merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ + 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 merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ + 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 merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ + 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('merchantCenterAccountLink', () => { + const fakePath = "/rendered/path/merchantCenterAccountLink"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + merchant_center_account_link: "merchantCenterAccountLinkValue", + }; + const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.merchantCenterAccountLinkPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.merchantCenterAccountLinkPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('merchantCenterAccountLinkPath', () => { + const result = client.merchantCenterAccountLinkPath("projectValue", "locationValue", "catalogValue", "merchantCenterAccountLinkValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromMerchantCenterAccountLinkName', () => { + const result = client.matchProjectFromMerchantCenterAccountLinkName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromMerchantCenterAccountLinkName', () => { + const result = client.matchLocationFromMerchantCenterAccountLinkName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromMerchantCenterAccountLinkName', () => { + const result = client.matchCatalogFromMerchantCenterAccountLinkName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName', () => { + const result = client.matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName(fakePath); + assert.strictEqual(result, "merchantCenterAccountLinkValue"); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('model', () => { + const fakePath = "/rendered/path/model"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + model: "modelValue", + }; + const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.modelPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, "modelValue"); + assert((client.pathTemplates.modelPathTemplate.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 merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ + 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 merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ + 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/google-cloud-retail/v2alpha/test/gapic_model_service_v2alpha.ts b/owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_model_service_v2alpha.ts new file mode 100644 index 00000000000..b44a338af49 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_model_service_v2alpha.ts @@ -0,0 +1,2150 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This 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 modelserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v2alpha.ModelServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = modelserviceModule.v2alpha.ModelServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = modelserviceModule.v2alpha.ModelServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = modelserviceModule.v2alpha.ModelServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.modelServiceStub, undefined); + await client.initialize(); + assert(client.modelServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.modelServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.modelServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + 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 modelserviceModule.v2alpha.ModelServiceClient({ + 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('getModel', () => { + it('invokes getModel without error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.GetModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.GetModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.Model() + ); + client.innerApiCalls.getModel = stubSimpleCall(expectedResponse); + const [response] = await client.getModel(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getModel without error using callback', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.GetModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.GetModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.Model() + ); + client.innerApiCalls.getModel = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getModel( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IModel|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getModel with error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.GetModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.GetModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getModel = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getModel(request), expectedError); + const actualRequest = (client.innerApiCalls.getModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getModel with closed client', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.GetModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.GetModelRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getModel(request), expectedError); + }); + }); + + describe('pauseModel', () => { + it('invokes pauseModel without error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.PauseModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.PauseModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.Model() + ); + client.innerApiCalls.pauseModel = stubSimpleCall(expectedResponse); + const [response] = await client.pauseModel(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.pauseModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.pauseModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pauseModel without error using callback', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.PauseModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.PauseModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.Model() + ); + client.innerApiCalls.pauseModel = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.pauseModel( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IModel|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.pauseModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.pauseModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pauseModel with error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.PauseModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.PauseModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.pauseModel = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.pauseModel(request), expectedError); + const actualRequest = (client.innerApiCalls.pauseModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.pauseModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pauseModel with closed client', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.PauseModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.PauseModelRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.pauseModel(request), expectedError); + }); + }); + + describe('resumeModel', () => { + it('invokes resumeModel without error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ResumeModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ResumeModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.Model() + ); + client.innerApiCalls.resumeModel = stubSimpleCall(expectedResponse); + const [response] = await client.resumeModel(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.resumeModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resumeModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resumeModel without error using callback', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ResumeModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ResumeModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.Model() + ); + client.innerApiCalls.resumeModel = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.resumeModel( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IModel|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.resumeModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resumeModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resumeModel with error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ResumeModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ResumeModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resumeModel = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.resumeModel(request), expectedError); + const actualRequest = (client.innerApiCalls.resumeModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resumeModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resumeModel with closed client', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ResumeModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ResumeModelRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.resumeModel(request), expectedError); + }); + }); + + describe('deleteModel', () => { + it('invokes deleteModel without error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.DeleteModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.DeleteModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteModel = stubSimpleCall(expectedResponse); + const [response] = await client.deleteModel(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteModel without error using callback', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.DeleteModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.DeleteModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteModel = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteModel( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteModel with error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.DeleteModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.DeleteModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteModel = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteModel(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteModel with closed client', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.DeleteModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.DeleteModelRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteModel(request), expectedError); + }); + }); + + describe('updateModel', () => { + it('invokes updateModel without error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.UpdateModelRequest() + ); + request.model ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateModelRequest', ['model', 'name']); + request.model.name = defaultValue1; + const expectedHeaderRequestParams = `model.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.Model() + ); + client.innerApiCalls.updateModel = stubSimpleCall(expectedResponse); + const [response] = await client.updateModel(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateModel without error using callback', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.UpdateModelRequest() + ); + request.model ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateModelRequest', ['model', 'name']); + request.model.name = defaultValue1; + const expectedHeaderRequestParams = `model.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.Model() + ); + client.innerApiCalls.updateModel = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateModel( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IModel|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateModel with error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.UpdateModelRequest() + ); + request.model ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateModelRequest', ['model', 'name']); + request.model.name = defaultValue1; + const expectedHeaderRequestParams = `model.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateModel = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateModel(request), expectedError); + const actualRequest = (client.innerApiCalls.updateModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateModel with closed client', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.UpdateModelRequest() + ); + request.model ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateModelRequest', ['model', 'name']); + request.model.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateModel(request), expectedError); + }); + }); + + describe('createModel', () => { + it('invokes createModel without error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.CreateModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.CreateModelRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createModel = stubLongRunningCall(expectedResponse); + const [operation] = await client.createModel(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createModel without error using callback', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.CreateModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.CreateModelRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createModel = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createModel( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createModel with call error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.CreateModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.CreateModelRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createModel = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createModel(request), expectedError); + const actualRequest = (client.innerApiCalls.createModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createModel with LRO error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.CreateModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.CreateModelRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createModel = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createModel(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.createModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateModelProgress without error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateModelProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateModelProgress with error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCreateModelProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('tuneModel', () => { + it('invokes tuneModel without error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.TuneModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.TuneModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.tuneModel = stubLongRunningCall(expectedResponse); + const [operation] = await client.tuneModel(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.tuneModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.tuneModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes tuneModel without error using callback', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.TuneModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.TuneModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.tuneModel = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.tuneModel( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.tuneModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.tuneModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes tuneModel with call error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.TuneModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.TuneModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.tuneModel = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.tuneModel(request), expectedError); + const actualRequest = (client.innerApiCalls.tuneModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.tuneModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes tuneModel with LRO error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.TuneModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.TuneModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.tuneModel = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.tuneModel(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.tuneModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.tuneModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkTuneModelProgress without error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkTuneModelProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkTuneModelProgress with error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkTuneModelProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listModels', () => { + it('invokes listModels without error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListModelsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ListModelsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Model()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Model()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Model()), + ]; + client.innerApiCalls.listModels = stubSimpleCall(expectedResponse); + const [response] = await client.listModels(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listModels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listModels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listModels without error using callback', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListModelsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ListModelsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Model()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Model()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Model()), + ]; + client.innerApiCalls.listModels = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listModels( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IModel[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listModels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listModels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listModels with error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListModelsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ListModelsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listModels = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listModels(request), expectedError); + const actualRequest = (client.innerApiCalls.listModels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listModels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listModelsStream without error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListModelsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ListModelsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Model()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Model()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Model()), + ]; + client.descriptors.page.listModels.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listModelsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2alpha.Model[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2alpha.Model) => { + 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.listModels.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listModels, request)); + assert( + (client.descriptors.page.listModels.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listModelsStream with error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListModelsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ListModelsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listModels.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listModelsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2alpha.Model[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2alpha.Model) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listModels.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listModels, request)); + assert( + (client.descriptors.page.listModels.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listModels without error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListModelsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ListModelsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Model()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Model()), + generateSampleMessage(new protos.google.cloud.retail.v2alpha.Model()), + ]; + client.descriptors.page.listModels.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2alpha.IModel[] = []; + const iterable = client.listModelsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listModels.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listModels.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listModels with error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListModelsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ListModelsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listModels.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listModelsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.retail.v2alpha.IModel[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listModels.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listModels.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getLocation without error using callback', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getLocation(request, expectedOptions), expectedError); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.getOperation(request)}, expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('attributesConfig', () => { + const fakePath = "/rendered/path/attributesConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + 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 modelserviceModule.v2alpha.ModelServiceClient({ + 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 modelserviceModule.v2alpha.ModelServiceClient({ + 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 modelserviceModule.v2alpha.ModelServiceClient({ + 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('merchantCenterAccountLink', () => { + const fakePath = "/rendered/path/merchantCenterAccountLink"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + merchant_center_account_link: "merchantCenterAccountLinkValue", + }; + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.merchantCenterAccountLinkPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.merchantCenterAccountLinkPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('merchantCenterAccountLinkPath', () => { + const result = client.merchantCenterAccountLinkPath("projectValue", "locationValue", "catalogValue", "merchantCenterAccountLinkValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromMerchantCenterAccountLinkName', () => { + const result = client.matchProjectFromMerchantCenterAccountLinkName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromMerchantCenterAccountLinkName', () => { + const result = client.matchLocationFromMerchantCenterAccountLinkName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromMerchantCenterAccountLinkName', () => { + const result = client.matchCatalogFromMerchantCenterAccountLinkName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName', () => { + const result = client.matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName(fakePath); + assert.strictEqual(result, "merchantCenterAccountLinkValue"); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('model', () => { + const fakePath = "/rendered/path/model"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + model: "modelValue", + }; + const client = new modelserviceModule.v2alpha.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.modelPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, "modelValue"); + assert((client.pathTemplates.modelPathTemplate.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 modelserviceModule.v2alpha.ModelServiceClient({ + 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 modelserviceModule.v2alpha.ModelServiceClient({ + 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/google-cloud-retail/v2alpha/test/gapic_prediction_service_v2alpha.ts b/owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_prediction_service_v2alpha.ts new file mode 100644 index 00000000000..ba576dee231 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_prediction_service_v2alpha.ts @@ -0,0 +1,1118 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This 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, operationsProtos, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function 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.PredictionServiceClient', () => { + describe('Common methods', () => { + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.PredictRequest', ['placement']); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.predict as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.predict as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.PredictRequest', ['placement']); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.predict as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.predict as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.PredictRequest', ['placement']); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.predict = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.predict(request), expectedError); + const actualRequest = (client.innerApiCalls.predict as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.predict as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.PredictRequest', ['placement']); + request.placement = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.predict(request), expectedError); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getLocation without error using callback', async () => { + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getLocation(request, expectedOptions), expectedError); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.getOperation(request)}, expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('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('merchantCenterAccountLink', () => { + const fakePath = "/rendered/path/merchantCenterAccountLink"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + merchant_center_account_link: "merchantCenterAccountLinkValue", + }; + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.merchantCenterAccountLinkPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.merchantCenterAccountLinkPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('merchantCenterAccountLinkPath', () => { + const result = client.merchantCenterAccountLinkPath("projectValue", "locationValue", "catalogValue", "merchantCenterAccountLinkValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromMerchantCenterAccountLinkName', () => { + const result = client.matchProjectFromMerchantCenterAccountLinkName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromMerchantCenterAccountLinkName', () => { + const result = client.matchLocationFromMerchantCenterAccountLinkName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromMerchantCenterAccountLinkName', () => { + const result = client.matchCatalogFromMerchantCenterAccountLinkName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName', () => { + const result = client.matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName(fakePath); + assert.strictEqual(result, "merchantCenterAccountLinkValue"); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('model', () => { + const fakePath = "/rendered/path/model"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + model: "modelValue", + }; + const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.modelPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, "modelValue"); + assert((client.pathTemplates.modelPathTemplate.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/google-cloud-retail/v2alpha/test/gapic_product_service_v2alpha.ts b/owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_product_service_v2alpha.ts new file mode 100644 index 00000000000..ffcd6f348ce --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_product_service_v2alpha.ts @@ -0,0 +1,2870 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This 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, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v2alpha.ProductServiceClient', () => { + describe('Common methods', () => { + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.CreateProductRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProduct without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.CreateProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.CreateProductRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProduct with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.CreateProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.CreateProductRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createProduct(request), expectedError); + const actualRequest = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProduct with closed client', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.CreateProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.CreateProductRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createProduct(request), expectedError); + }); + }); + + describe('getProduct', () => { + it('invokes getProduct without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.GetProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProduct without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.GetProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProduct with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.GetProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getProduct(request), expectedError); + const actualRequest = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProduct with closed client', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.GetProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getProduct(request), expectedError); + }); + }); + + describe('updateProduct', () => { + it('invokes updateProduct without error', async () => { + const client = new 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateProductRequest', ['product', 'name']); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProduct without error using callback', async () => { + const client = new 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateProductRequest', ['product', 'name']); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProduct with error', async () => { + const client = new 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateProductRequest', ['product', 'name']); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateProduct(request), expectedError); + const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProduct with closed client', async () => { + const client = new 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateProductRequest', ['product', 'name']); + request.product.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateProduct(request), expectedError); + }); + }); + + describe('deleteProduct', () => { + it('invokes deleteProduct without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.DeleteProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.DeleteProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteProduct = stubSimpleCall(expectedResponse); + const [response] = await client.deleteProduct(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProduct without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.DeleteProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.DeleteProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteProduct( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProduct with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.DeleteProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.DeleteProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteProduct(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProduct with closed client', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.DeleteProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.DeleteProductRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteProduct(request), expectedError); + }); + }); + + describe('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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.PurgeProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.purgeProducts = stubLongRunningCall(expectedResponse); + const [operation] = await client.purgeProducts(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes purgeProducts without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.PurgeProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.PurgeProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.purgeProducts = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.purgeProducts( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes purgeProducts with call error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.PurgeProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.PurgeProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeProducts = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.purgeProducts(request), expectedError); + const actualRequest = (client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes purgeProducts with LRO error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.PurgeProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.PurgeProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeProducts = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.purgeProducts(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.purgeProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkPurgeProductsProgress without error', async () => { + const client = new 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ImportProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.importProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ImportProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.importProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ImportProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importProducts = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importProducts(request), expectedError); + const actualRequest = (client.innerApiCalls.importProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ImportProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importProducts = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importProducts(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.importProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.SetInventoryRequest', ['inventory', 'name']); + request.inventory.name = defaultValue1; + const expectedHeaderRequestParams = `inventory.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.setInventory as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setInventory as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.SetInventoryRequest', ['inventory', 'name']); + request.inventory.name = defaultValue1; + const expectedHeaderRequestParams = `inventory.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.setInventory as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setInventory as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.SetInventoryRequest', ['inventory', 'name']); + request.inventory.name = defaultValue1; + const expectedHeaderRequestParams = `inventory.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setInventory = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.setInventory(request), expectedError); + const actualRequest = (client.innerApiCalls.setInventory as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setInventory as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.SetInventoryRequest', ['inventory', 'name']); + request.inventory.name = defaultValue1; + const expectedHeaderRequestParams = `inventory.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setInventory = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.setInventory(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.setInventory as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setInventory as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.addFulfillmentPlaces(request), expectedError); + const actualRequest = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.addFulfillmentPlaces(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.removeFulfillmentPlaces(request), expectedError); + const actualRequest = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.removeFulfillmentPlaces(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.AddLocalInventoriesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.addLocalInventories as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addLocalInventories as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.AddLocalInventoriesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.addLocalInventories as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addLocalInventories as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.AddLocalInventoriesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addLocalInventories = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.addLocalInventories(request), expectedError); + const actualRequest = (client.innerApiCalls.addLocalInventories as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addLocalInventories as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.AddLocalInventoriesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addLocalInventories = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.addLocalInventories(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.addLocalInventories as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addLocalInventories as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.removeLocalInventories as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeLocalInventories as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.removeLocalInventories as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeLocalInventories as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeLocalInventories = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.removeLocalInventories(request), expectedError); + const actualRequest = (client.innerApiCalls.removeLocalInventories as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeLocalInventories as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeLocalInventories = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.removeLocalInventories(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.removeLocalInventories as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeLocalInventories as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProducts without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProducts with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listProducts = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProducts(request), expectedError); + const actualRequest = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductsStream without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listProductsStream with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProducts.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProductsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.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( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProducts without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProducts with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2alpha.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProductsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.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( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getLocation without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getLocation(request, expectedOptions), expectedError); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.getOperation(request)}, expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('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('merchantCenterAccountLink', () => { + const fakePath = "/rendered/path/merchantCenterAccountLink"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + merchant_center_account_link: "merchantCenterAccountLinkValue", + }; + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.merchantCenterAccountLinkPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.merchantCenterAccountLinkPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('merchantCenterAccountLinkPath', () => { + const result = client.merchantCenterAccountLinkPath("projectValue", "locationValue", "catalogValue", "merchantCenterAccountLinkValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromMerchantCenterAccountLinkName', () => { + const result = client.matchProjectFromMerchantCenterAccountLinkName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromMerchantCenterAccountLinkName', () => { + const result = client.matchLocationFromMerchantCenterAccountLinkName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromMerchantCenterAccountLinkName', () => { + const result = client.matchCatalogFromMerchantCenterAccountLinkName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName', () => { + const result = client.matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName(fakePath); + assert.strictEqual(result, "merchantCenterAccountLinkValue"); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('model', () => { + const fakePath = "/rendered/path/model"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + model: "modelValue", + }; + const client = new productserviceModule.v2alpha.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.modelPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, "modelValue"); + assert((client.pathTemplates.modelPathTemplate.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/google-cloud-retail/v2alpha/test/gapic_search_service_v2alpha.ts b/owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_search_service_v2alpha.ts new file mode 100644 index 00000000000..2499cbc9da5 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_search_service_v2alpha.ts @@ -0,0 +1,1390 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This 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, operationsProtos, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function 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', () => { + describe('Common methods', () => { + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.SearchRequest', ['placement']); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.search as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.search as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.SearchRequest', ['placement']); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.search as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.search as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.SearchRequest', ['placement']); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.search = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.search(request), expectedError); + const actualRequest = (client.innerApiCalls.search as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.search as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.SearchRequest', ['placement']); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + 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( + (client.descriptors.page.search.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.SearchRequest', ['placement']); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + 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( + (client.descriptors.page.search.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.SearchRequest', ['placement']); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + 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( + (client.descriptors.page.search.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.SearchRequest', ['placement']); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + 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( + (client.descriptors.page.search.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getLocation without error using callback', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getLocation(request, expectedOptions), expectedError); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.getOperation(request)}, expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('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('experiment', () => { + const fakePath = "/rendered/path/experiment"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + experiment: "experimentValue", + }; + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.experimentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.experimentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('experimentPath', () => { + const result = client.experimentPath("projectValue", "locationValue", "catalogValue", "experimentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.experimentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromExperimentName', () => { + const result = client.matchProjectFromExperimentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.experimentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromExperimentName', () => { + const result = client.matchLocationFromExperimentName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.experimentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromExperimentName', () => { + const result = client.matchCatalogFromExperimentName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.experimentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchExperimentFromExperimentName', () => { + const result = client.matchExperimentFromExperimentName(fakePath); + assert.strictEqual(result, "experimentValue"); + assert((client.pathTemplates.experimentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('merchantCenterAccountLink', () => { + const fakePath = "/rendered/path/merchantCenterAccountLink"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + merchant_center_account_link: "merchantCenterAccountLinkValue", + }; + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.merchantCenterAccountLinkPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.merchantCenterAccountLinkPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('merchantCenterAccountLinkPath', () => { + const result = client.merchantCenterAccountLinkPath("projectValue", "locationValue", "catalogValue", "merchantCenterAccountLinkValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromMerchantCenterAccountLinkName', () => { + const result = client.matchProjectFromMerchantCenterAccountLinkName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromMerchantCenterAccountLinkName', () => { + const result = client.matchLocationFromMerchantCenterAccountLinkName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromMerchantCenterAccountLinkName', () => { + const result = client.matchCatalogFromMerchantCenterAccountLinkName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName', () => { + const result = client.matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName(fakePath); + assert.strictEqual(result, "merchantCenterAccountLinkValue"); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('model', () => { + const fakePath = "/rendered/path/model"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + model: "modelValue", + }; + const client = new searchserviceModule.v2alpha.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.modelPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, "modelValue"); + assert((client.pathTemplates.modelPathTemplate.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/google-cloud-retail/v2alpha/test/gapic_serving_config_service_v2alpha.ts b/owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_serving_config_service_v2alpha.ts new file mode 100644 index 00000000000..6c336584cf5 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_serving_config_service_v2alpha.ts @@ -0,0 +1,1934 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This 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, operationsProtos, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function 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', () => { + describe('Common methods', () => { + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.CreateServingConfigRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.createServingConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createServingConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.CreateServingConfigRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.createServingConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createServingConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.CreateServingConfigRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createServingConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createServingConfig(request), expectedError); + const actualRequest = (client.innerApiCalls.createServingConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createServingConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.CreateServingConfigRequest', ['parent']); + request.parent = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.DeleteServingConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteServingConfig = stubSimpleCall(expectedResponse); + const [response] = await client.deleteServingConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteServingConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteServingConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.DeleteServingConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.deleteServingConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteServingConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.DeleteServingConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteServingConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteServingConfig(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteServingConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteServingConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.DeleteServingConfigRequest', ['name']); + request.name = defaultValue1; + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateServingConfigRequest', ['servingConfig', 'name']); + request.servingConfig.name = defaultValue1; + const expectedHeaderRequestParams = `serving_config.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.updateServingConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateServingConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateServingConfigRequest', ['servingConfig', 'name']); + request.servingConfig.name = defaultValue1; + const expectedHeaderRequestParams = `serving_config.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.updateServingConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateServingConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateServingConfigRequest', ['servingConfig', 'name']); + request.servingConfig.name = defaultValue1; + const expectedHeaderRequestParams = `serving_config.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateServingConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateServingConfig(request), expectedError); + const actualRequest = (client.innerApiCalls.updateServingConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateServingConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateServingConfigRequest', ['servingConfig', 'name']); + request.servingConfig.name = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.GetServingConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getServingConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getServingConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.GetServingConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getServingConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getServingConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.GetServingConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getServingConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getServingConfig(request), expectedError); + const actualRequest = (client.innerApiCalls.getServingConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getServingConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.GetServingConfigRequest', ['name']); + request.name = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.AddControlRequest', ['servingConfig']); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.addControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.AddControlRequest', ['servingConfig']); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.addControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.AddControlRequest', ['servingConfig']); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addControl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.addControl(request), expectedError); + const actualRequest = (client.innerApiCalls.addControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.AddControlRequest', ['servingConfig']); + request.servingConfig = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.RemoveControlRequest', ['servingConfig']); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.removeControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.RemoveControlRequest', ['servingConfig']); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.removeControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.RemoveControlRequest', ['servingConfig']); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeControl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.removeControl(request), expectedError); + const actualRequest = (client.innerApiCalls.removeControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.RemoveControlRequest', ['servingConfig']); + request.servingConfig = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ListServingConfigsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.listServingConfigs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listServingConfigs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ListServingConfigsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.listServingConfigs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listServingConfigs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ListServingConfigsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listServingConfigs = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listServingConfigs(request), expectedError); + const actualRequest = (client.innerApiCalls.listServingConfigs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listServingConfigs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ListServingConfigsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listServingConfigs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ListServingConfigsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listServingConfigs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ListServingConfigsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ListServingConfigsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getLocation without error using callback', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getLocation(request, expectedOptions), expectedError); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.getOperation(request)}, expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('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('merchantCenterAccountLink', () => { + const fakePath = "/rendered/path/merchantCenterAccountLink"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + merchant_center_account_link: "merchantCenterAccountLinkValue", + }; + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.merchantCenterAccountLinkPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.merchantCenterAccountLinkPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('merchantCenterAccountLinkPath', () => { + const result = client.merchantCenterAccountLinkPath("projectValue", "locationValue", "catalogValue", "merchantCenterAccountLinkValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromMerchantCenterAccountLinkName', () => { + const result = client.matchProjectFromMerchantCenterAccountLinkName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromMerchantCenterAccountLinkName', () => { + const result = client.matchLocationFromMerchantCenterAccountLinkName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromMerchantCenterAccountLinkName', () => { + const result = client.matchCatalogFromMerchantCenterAccountLinkName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName', () => { + const result = client.matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName(fakePath); + assert.strictEqual(result, "merchantCenterAccountLinkValue"); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('model', () => { + const fakePath = "/rendered/path/model"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + model: "modelValue", + }; + const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.modelPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, "modelValue"); + assert((client.pathTemplates.modelPathTemplate.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/google-cloud-retail/v2alpha/test/gapic_user_event_service_v2alpha.ts b/owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_user_event_service_v2alpha.ts new file mode 100644 index 00000000000..85baa7f10d7 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_user_event_service_v2alpha.ts @@ -0,0 +1,1704 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This 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, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function 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.UserEventServiceClient', () => { + describe('Common methods', () => { + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.WriteUserEventRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.WriteUserEventRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.WriteUserEventRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.writeUserEvent = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.writeUserEvent(request), expectedError); + const actualRequest = (client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.WriteUserEventRequest', ['parent']); + request.parent = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.CollectUserEventRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.api.HttpBody() + ); + client.innerApiCalls.collectUserEvent = stubSimpleCall(expectedResponse); + const [response] = await client.collectUserEvent(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.CollectUserEventRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.CollectUserEventRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.collectUserEvent = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.collectUserEvent(request), expectedError); + const actualRequest = (client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.CollectUserEventRequest', ['parent']); + request.parent = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.PurgeUserEventsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.purgeUserEvents as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.purgeUserEvents as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.PurgeUserEventsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.purgeUserEvents as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.purgeUserEvents as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.PurgeUserEventsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeUserEvents = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.purgeUserEvents(request), expectedError); + const actualRequest = (client.innerApiCalls.purgeUserEvents as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.purgeUserEvents as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.PurgeUserEventsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeUserEvents = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.purgeUserEvents(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.purgeUserEvents as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.purgeUserEvents as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ImportUserEventsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ImportUserEventsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ImportUserEventsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importUserEvents = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importUserEvents(request), expectedError); + const actualRequest = (client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.ImportUserEventsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importUserEvents = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importUserEvents(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.RejoinUserEventsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.rejoinUserEvents as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.rejoinUserEvents as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.RejoinUserEventsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.rejoinUserEvents as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.rejoinUserEvents as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.RejoinUserEventsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.rejoinUserEvents(request), expectedError); + const actualRequest = (client.innerApiCalls.rejoinUserEvents as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.rejoinUserEvents as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2alpha.RejoinUserEventsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.rejoinUserEvents(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.rejoinUserEvents as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.rejoinUserEvents as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getLocation without error using callback', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getLocation(request, expectedOptions), expectedError); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.getOperation(request)}, expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('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('merchantCenterAccountLink', () => { + const fakePath = "/rendered/path/merchantCenterAccountLink"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + merchant_center_account_link: "merchantCenterAccountLinkValue", + }; + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.merchantCenterAccountLinkPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.merchantCenterAccountLinkPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('merchantCenterAccountLinkPath', () => { + const result = client.merchantCenterAccountLinkPath("projectValue", "locationValue", "catalogValue", "merchantCenterAccountLinkValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromMerchantCenterAccountLinkName', () => { + const result = client.matchProjectFromMerchantCenterAccountLinkName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromMerchantCenterAccountLinkName', () => { + const result = client.matchLocationFromMerchantCenterAccountLinkName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromMerchantCenterAccountLinkName', () => { + const result = client.matchCatalogFromMerchantCenterAccountLinkName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName', () => { + const result = client.matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName(fakePath); + assert.strictEqual(result, "merchantCenterAccountLinkValue"); + assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('model', () => { + const fakePath = "/rendered/path/model"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + model: "modelValue", + }; + const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.modelPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, "modelValue"); + assert((client.pathTemplates.modelPathTemplate.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/google-cloud-retail/v2alpha/tsconfig.json b/owl-bot-staging/google-cloud-retail/v2alpha/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2alpha/webpack.config.js b/owl-bot-staging/google-cloud-retail/v2alpha/webpack.config.js new file mode 100644 index 00000000000..f2c58f2530c --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2beta/.eslintignore b/owl-bot-staging/google-cloud-retail/v2beta/.eslintignore new file mode 100644 index 00000000000..cfc348ec4d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/google-cloud-retail/v2beta/.eslintrc.json b/owl-bot-staging/google-cloud-retail/v2beta/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/google-cloud-retail/v2beta/.gitignore b/owl-bot-staging/google-cloud-retail/v2beta/.gitignore new file mode 100644 index 00000000000..d4f03a0df2e --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2beta/.jsdoc.js b/owl-bot-staging/google-cloud-retail/v2beta/.jsdoc.js new file mode 100644 index 00000000000..66e9db869e8 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 2023 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/retail', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/google-cloud-retail/v2beta/.mocharc.js b/owl-bot-staging/google-cloud-retail/v2beta/.mocharc.js new file mode 100644 index 00000000000..1a38f257db7 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/.mocharc.js @@ -0,0 +1,33 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +const config = { + "enable-source-maps": true, + "throw-deprecation": true, + "timeout": 10000 +} +if (process.env.MOCHA_THROW_DEPRECATION === 'false') { + delete config['throw-deprecation']; +} +if (process.env.MOCHA_REPORTER) { + config.reporter = process.env.MOCHA_REPORTER; +} +if (process.env.MOCHA_REPORTER_OUTPUT) { + config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; +} +module.exports = config diff --git a/owl-bot-staging/google-cloud-retail/v2beta/.prettierrc.js b/owl-bot-staging/google-cloud-retail/v2beta/.prettierrc.js new file mode 100644 index 00000000000..55639e70f9e --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/.prettierrc.js @@ -0,0 +1,22 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/owl-bot-staging/google-cloud-retail/v2beta/README.md b/owl-bot-staging/google-cloud-retail/v2beta/README.md new file mode 100644 index 00000000000..822c4573817 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/README.md @@ -0,0 +1 @@ +Retail: Nodejs Client diff --git a/owl-bot-staging/google-cloud-retail/v2beta/linkinator.config.json b/owl-bot-staging/google-cloud-retail/v2beta/linkinator.config.json new file mode 100644 index 00000000000..befd23c8633 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2beta/package.json b/owl-bot-staging/google-cloud-retail/v2beta/package.json new file mode 100644 index 00000000000..468da5696b6 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/package.json @@ -0,0 +1,72 @@ +{ + "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", + "model service", + "prediction service", + "product service", + "search service", + "serving config service", + "user event service" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^3.5.7" + }, + "devDependencies": { + "@types/mocha": "^10.0.1", + "@types/node": "^18.11.18", + "@types/sinon": "^10.0.13", + "c8": "^7.12.0", + "gts": "^3.1.1", + "jsdoc": "^4.0.0", + "jsdoc-fresh": "^2.0.1", + "jsdoc-region-tag": "^2.0.1", + "linkinator": "^4.1.2", + "mocha": "^10.2.0", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^15.0.1", + "ts-loader": "^8.4.0", + "typescript": "^4.8.4", + "webpack": "^4.46.0", + "webpack-cli": "^4.10.0" + }, + "engines": { + "node": ">=v12" + } +} diff --git a/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/catalog.proto b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/catalog.proto new file mode 100644 index 00000000000..83e6d10cd45 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/catalog.proto @@ -0,0 +1,476 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 = "cloud.google.com/go/retail/apiv2beta/retailpb;retailpb"; +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` (incompatible with Retail Search): 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 [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.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 [Product + // levels](https://cloud.google.com/retail/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. + 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. + 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. + SEARCHABLE_OPTION_UNSPECIFIED = 0; + + // Searchable option enabled for an attribute. + SEARCHABLE_ENABLED = 1; + + // Searchable option disabled for an attribute. + SEARCHABLE_DISABLED = 2; + } + + // The status of the exact-searchable option of a catalog attribute. + enum ExactSearchableOption { + // Value used when unset. + EXACT_SEARCHABLE_OPTION_UNSPECIFIED = 0; + + // Exact searchable option enabled for an attribute. + EXACT_SEARCHABLE_ENABLED = 1; + + // Exact searchable option disabled for an attribute. + EXACT_SEARCHABLE_DISABLED = 2; + } + + // The status of the retrievable option of a catalog attribute. + enum RetrievableOption { + // Value used when unset. + RETRIEVABLE_OPTION_UNSPECIFIED = 0; + + // Retrievable option enabled for an attribute. + RETRIEVABLE_ENABLED = 1; + + // Retrievable option disabled for an attribute. + RETRIEVABLE_DISABLED = 2; + } + + // Required. Attribute name. + // For example: `color`, `brands`, `attributes.custom_attribute`, such as + // `attributes.xyz`. + // To be indexable, the attribute name can contain only alpha-numeric + // characters and underscores. For example, an attribute named + // `attributes.abc_xyz` can be indexed, but an attribute named + // `attributes.abc-xyz` cannot be indexed. + // + // If the attribute key starts with `attributes.`, then the attribute is a + // custom attribute. Attributes such as `brands`, `patterns`, and `title` are + // built-in and called system attributes. + 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 + // [CatalogService.AddCatalogAttribute][google.cloud.retail.v2beta.CatalogService.AddCatalogAttribute], + // [CatalogService.ImportCatalogAttributes][], or + // [CatalogService.UpdateAttributesConfig][google.cloud.retail.v2beta.CatalogService.UpdateAttributesConfig] + // APIs. This field is `False` for pre-loaded + // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute]s. + // + // Only pre-loaded [catalog + // attributes][google.cloud.retail.v2beta.CatalogAttribute] that are neither + // in use by products nor predefined can be deleted. [Catalog + // attributes][google.cloud.retail.v2beta.CatalogAttribute] that are + // either in use by products or are predefined attributes 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]. + // + // Must be specified, otherwise throws INVALID_FORMAT error. + 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. + // + // Must be specified, otherwise throws INVALID_FORMAT error. + 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. + // + // Must be specified, otherwise throws INVALID_FORMAT error. + SearchableOption searchable_option = 7; + + // When + // [AttributesConfig.attribute_config_level][google.cloud.retail.v2beta.AttributesConfig.attribute_config_level] + // is CATALOG_LEVEL_ATTRIBUTE_CONFIG, if RECOMMENDATIONS_FILTERING_ENABLED, + // attribute values are filterable for recommendations. + // This option works for categorical features only, + // does not work for numerical features, inventory filtering. + RecommendationsFilteringOption recommendations_filtering_option = 8; + + // If EXACT_SEARCHABLE_ENABLED, attribute values will be exact searchable. + // This property only applies to textual custom attributes and requires + // indexable set to enabled to enable exact-searchable. If unset, the server + // behavior defaults to + // [EXACT_SEARCHABLE_DISABLED][google.cloud.retail.v2beta.CatalogAttribute.ExactSearchableOption.EXACT_SEARCHABLE_DISABLED]. + ExactSearchableOption exact_searchable_option = 11; + + // If RETRIEVABLE_ENABLED, attribute values are retrievable in the search + // results. If unset, the server behavior defaults to + // [RETRIEVABLE_DISABLED][google.cloud.retail.v2beta.CatalogAttribute.RetrievableOption.RETRIEVABLE_DISABLED]. + RetrievableOption retrievable_option = 12; +} + +// 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. Default + // value is 20. If left unset or set to 0, then will fallback to default + // value. + // + // Value range is 1 to 20. + 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. + // + // Value range is 1 to 20. + 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 source data for the latest import of the autocomplete + // suggestion phrases. + 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 source data for the latest import of the autocomplete + // denylist phrases. + CompletionDataInputConfig denylist_input_config = 7 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Name of the 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 source data for the latest import of the autocomplete + // allowlist phrases. + CompletionDataInputConfig allowlist_input_config = 9 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Name of the 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 is given in [Included + // destination](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; + + // Criteria for the Merchant Center feeds to be ingested via the link. + // All offers will be ingested if the list is empty. + // Otherwise the offers will be ingested from selected feeds. + repeated MerchantCenterFeedFilter feeds = 6; +} + +// Merchant Center Feed filter criterion. +message MerchantCenterFeedFilter { + // Merchant Center primary feed ID. + int64 primary_feed_id = 1; + + // Merchant Center primary feed name. The name is used for the display + // purposes only. + string primary_feed_name = 2; +} + +// 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/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/catalog_service.proto b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/catalog_service.proto new file mode 100644 index 00000000000..337111764f1 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/catalog_service.proto @@ -0,0 +1,527 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 = "cloud.google.com/go/retail/apiv2beta/retailpb;retailpb"; +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: "*" + }; + } + + // Removes all specified + // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute]s from the + // [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig]. + rpc BatchRemoveCatalogAttributes(BatchRemoveCatalogAttributesRequest) + returns (BatchRemoveCatalogAttributesResponse) { + option (google.api.http) = { + post: "/v2beta/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:batchRemoveCatalogAttributes" + 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.BatchRemoveCatalogAttributes][google.cloud.retail.v2beta.CatalogService.BatchRemoveCatalogAttributes] +// method. +message BatchRemoveCatalogAttributesRequest { + // Required. The attributes config resource shared by all catalog attributes + // being deleted. 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 keys of the + // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute]s to delete. + // A maximum of 1000 catalog attributes can be deleted in a batch. + repeated string attribute_keys = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Response of the +// [CatalogService.BatchRemoveCatalogAttributes][google.cloud.retail.v2beta.CatalogService.BatchRemoveCatalogAttributes]. +message BatchRemoveCatalogAttributesResponse { + // Catalog attributes that were deleted. Only pre-loaded [catalog + // attributes][google.cloud.retail.v2beta.CatalogAttribute] that are + // neither [in + // use][google.cloud.retail.v2beta.CatalogAttribute.in_use] by + // products nor predefined can be deleted. + repeated string deleted_catalog_attributes = 1; + + // Catalog attributes that were reset. [Catalog + // attributes][google.cloud.retail.v2beta.CatalogAttribute] that are either + // [in use][google.cloud.retail.v2beta.CatalogAttribute.in_use] by products or + // are predefined attributes cannot be deleted; however, their configuration + // properties will reset to default values upon removal request. + repeated string reset_catalog_attributes = 2; +} + +// 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/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/common.proto b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/common.proto new file mode 100644 index 00000000000..1ffa26902e1 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/common.proto @@ -0,0 +1,793 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 = "cloud.google.com/go/retail/apiv2beta/retailpb;retailpb"; +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. In this case, server behavior 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; +} + +// If filtering for recommendations is enabled. +enum RecommendationsFilteringOption { + // Value used when unset. + // In this case, server behavior defaults to + // [RECOMMENDATIONS_FILTERING_DISABLED][google.cloud.retail.v2beta.RecommendationsFilteringOption.RECOMMENDATIONS_FILTERING_DISABLED]. + RECOMMENDATIONS_FILTERING_OPTION_UNSPECIFIED = 0; + + // Recommendation filtering is disabled. + RECOMMENDATIONS_FILTERING_DISABLED = 1; + + // Recommendation filtering is enabled. + RECOMMENDATIONS_FILTERING_ENABLED = 3; +} + +// The use case of Cloud Retail Search. +enum SearchSolutionUseCase { + // The value when it's unspecified. In this case, server behavior defaults to + // [SEARCH_SOLUTION_USE_CASE_SEARCH][google.cloud.retail.v2beta.SearchSolutionUseCase.SEARCH_SOLUTION_USE_CASE_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. + // For example, "a b c" is 3 terms and allowed, but " a b c d" is 4 terms + // and not allowed for a 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 rules only work for [controls][google.cloud.retail.v2beta.Control] +// with +// [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2beta.SolutionType.SOLUTION_TYPE_SEARCH]. +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][google.cloud.retail.v2beta.Condition.query_terms] + // provided is a global match. + // - 1 or more + // [Condition.query_terms][google.cloud.retail.v2beta.Condition.query_terms] + // provided are combined with OR operator. + // * Action Input: The request query and filter that are 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][google.cloud.retail.v2beta.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 75 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 is normally ignored unless + // [AttributesConfig.attribute_config_level][google.cloud.retail.v2beta.AttributesConfig.attribute_config_level] + // of the [Catalog][google.cloud.retail.v2beta.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.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 [deprecated = true]; + + // This field is normally ignored unless + // [AttributesConfig.attribute_config_level][google.cloud.retail.v2beta.AttributesConfig.attribute_config_level] + // of the [Catalog][google.cloud.retail.v2beta.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.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 [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.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 not be larger than 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. + // 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]. If set, + // [original_price][google.cloud.retail.v2beta.PriceInfo.original_price] + // should be greater than or equal to + // [price][google.cloud.retail.v2beta.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.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. 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.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/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/completion_service.proto b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/completion_service.proto new file mode 100644 index 00000000000..9442028b908 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/completion_service.proto @@ -0,0 +1,220 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 = "cloud.google.com/go/retail/apiv2beta/retailpb;retailpb"; +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"; + +// Autocomplete service for retail. +// +// This feature is only available for users who have Retail Search enabled. +// 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. + // 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. + // 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" + }; + } +} + +// Autocomplete 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; + + // Note that this field applies for `user-data` dataset only. For requests + // with `cloud-retail` dataset, setting this field has no effect. + // + // 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. We recommend that you + // leave this field empty. + // + // It can 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 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][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; + + // The entity for customers that may run multiple different entities, domains, + // sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, + // `google.com`, `youtube.com`, etc. + // If this is set, it should be exactly matched with + // [UserEvent.entity][google.cloud.retail.v2beta.UserEvent.entity] to get + // per-entity autocomplete results. + string entity = 10; +} + +// Response of the autocomplete 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. It requires + // [UserEvent.product_details][google.cloud.retail.v2beta.UserEvent.product_details] + // is imported properly. + 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 case. + // + // * 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/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/control.proto b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/control.proto new file mode 100644 index 00000000000..e44cfdd672d --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/control.proto @@ -0,0 +1,100 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 = "cloud.google.com/go/retail/apiv2beta/retailpb;retailpb"; +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 metadata that can be linked to a +// [ServingConfig][google.cloud.retail.v2beta.ServingConfig] and affect search +// or recommendation results at serving time. +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. + // + // Note that this field is deprecated and will throw NOT_IMPLEMENTED if + // used for creating a control. + SearchRequest.FacetSpec facet_spec = 3 [deprecated = true]; + + // 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 + // config][google.cloud.retail.v2beta.ServingConfig] ids that are associated + // with this control in the same + // [Catalog][google.cloud.retail.v2beta.Catalog]. + // + // Note the association is managed via the + // [ServingConfig][google.cloud.retail.v2beta.ServingConfig], this is an + // output only denormalized view. + repeated string associated_serving_config_ids = 5 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Required. Immutable. The solution types that the control 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][google.cloud.retail.v2beta.SolutionType.SOLUTION_TYPE_SEARCH]. + repeated SolutionType solution_types = 6 [ + (google.api.field_behavior) = REQUIRED, + (google.api.field_behavior) = IMMUTABLE + ]; + + // 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][google.cloud.retail.v2beta.SearchSolutionUseCase.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; +} diff --git a/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/control_service.proto b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/control_service.proto new file mode 100644 index 00000000000..6a9a8707fb2 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/control_service.proto @@ -0,0 +1,185 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 = "cloud.google.com/go/retail/apiv2beta/retailpb;retailpb"; +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 update 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 by their parent + // [Catalog][google.cloud.retail.v2beta.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 get. 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/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/export_config.proto b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/export_config.proto new file mode 100644 index 00000000000..9efc0d195a6 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/export_config.proto @@ -0,0 +1,107 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 = "cloud.google.com/go/retail/apiv2beta/retailpb;retailpb"; +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 is +// 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; + + // This field is never set. + ExportErrorsConfig errors_config = 2; + + // Output result indicating where the data were exported to. + OutputResult output_result = 3; +} + +// 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; + + // This field is never set. + ExportErrorsConfig errors_config = 2; + + // Output result indicating where the data were exported to. + OutputResult output_result = 3; +} + +// Output result that stores the information about where the exported data is +// stored. +message OutputResult { + // The BigQuery location where the result is stored. + repeated BigQueryOutputResult bigquery_result = 1; + + // The Google Cloud Storage location where the result is stored. + repeated GcsOutputResult gcs_result = 2; +} + +// A BigQuery output result. +message BigQueryOutputResult { + // The ID of a BigQuery Dataset. + string dataset_id = 1; + + // The ID of a BigQuery Table. + string table_id = 2; +} + +// A Gcs output result. +message GcsOutputResult { + // The uri of Gcs output + string output_uri = 1; +} diff --git a/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/import_config.proto b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/import_config.proto new file mode 100644 index 00000000000..ad58554e650 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/import_config.proto @@ -0,0 +1,386 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 = "cloud.google.com/go/retail/apiv2beta/retailpb;retailpb"; +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. +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 in + // [ImportProductsRequest][google.cloud.retail.v2beta.ImportProductsRequest]. + 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`: + // The schema is available here: + // https://support.google.com/analytics/answer/7029846. + // + // Supported values for autocomplete 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 are 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. + 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, all fields are updated. + 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; + + // Full Pub/Sub topic name for receiving notification. If this field is set, + // when the import is finished, a notification is sent to + // specified Pub/Sub topic. The message data is 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.v2beta.ImportProductsRequest.parent]. + // Make sure that `service-@gcp-sa-retail.iam.gserviceaccount.com` has the + // `pubsub.topics.publish` IAM permission on the topic. + 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 is sent to + // specified Pub/Sub topic. The message data is 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 is +// 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 is sent to + // specified Pub/Sub topic. The message data is 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/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/model.proto b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/model.proto new file mode 100644 index 00000000000..92a3a43d5ea --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/model.proto @@ -0,0 +1,239 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "cloud.google.com/go/retail/apiv2beta/retailpb;retailpb"; +option java_multiple_files = true; +option java_outer_classname = "ModelProto"; +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 that describes the training and serving parameters of a +// [Model][google.cloud.retail.v2beta.Model]. A +// [Model][google.cloud.retail.v2beta.Model] can be associated with a +// [ServingConfig][google.cloud.retail.v2beta.ServingConfig] and then queried +// through the Predict API. +message Model { + option (google.api.resource) = { + type: "retail.googleapis.com/Model" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}" + }; + + // Represents an ordered combination of valid serving configs, which + // can be used for `PAGE_OPTIMIZATION` recommendations. + message ServingConfigList { + // Optional. A set of valid serving configs that may be used for + // `PAGE_OPTIMIZATION`. + repeated string serving_config_ids = 1 + [(google.api.field_behavior) = OPTIONAL]; + } + + // The serving state of the model. + enum ServingState { + // Unspecified serving state. + SERVING_STATE_UNSPECIFIED = 0; + + // The model is not serving. + INACTIVE = 1; + + // The model is serving and can be queried. + ACTIVE = 2; + + // The model is trained on tuned hyperparameters and can be + // queried. + TUNED = 3; + } + + // The training state of the model. + enum TrainingState { + // Unspecified training state. + TRAINING_STATE_UNSPECIFIED = 0; + + // The model training is paused. + PAUSED = 1; + + // The model is training. + TRAINING = 2; + } + + // Describes whether periodic tuning is enabled for this model + // or not. Periodic tuning is scheduled at most every three months. You can + // start a tuning process manually by using the `TuneModel` + // method, which starts a tuning process immediately and resets the quarterly + // schedule. Enabling or disabling periodic tuning does not affect any + // current tuning processes. + enum PeriodicTuningState { + // Unspecified default value, should never be explicitly set. + PERIODIC_TUNING_STATE_UNSPECIFIED = 0; + + // The model has periodic tuning disabled. Tuning + // can be reenabled by calling the `EnableModelPeriodicTuning` + // method or by calling the `TuneModel` method. + PERIODIC_TUNING_DISABLED = 1; + + // The model cannot be tuned with periodic tuning OR the + // `TuneModel` method. Hide the options in customer UI and + // reject any requests through the backend self serve API. + ALL_TUNING_DISABLED = 3; + + // The model has periodic tuning enabled. Tuning + // can be disabled by calling the `DisableModelPeriodicTuning` + // method. + PERIODIC_TUNING_ENABLED = 2; + } + + // Describes whether this model have sufficient training data + // to be continuously trained. + enum DataState { + // Unspecified default value, should never be explicitly set. + DATA_STATE_UNSPECIFIED = 0; + + // The model has sufficient training data. + DATA_OK = 1; + + // The model does not have sufficient training data. Error + // messages can be queried via Stackdriver. + DATA_ERROR = 2; + } + + // Required. The fully qualified resource name of the model. + // + // Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + // catalog_id has char limit of 50. + // recommendation_model_id has char limit of 40. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The display name of the model. + // + // Should be human readable, used to display Recommendation Models in the + // Retail Cloud Console Dashboard. UTF-8 encoded string with limit of 1024 + // characters. + string display_name = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. The training state that the model is in (e.g. + // `TRAINING` or `PAUSED`). + // + // Since part of the cost of running the service + // is frequency of training - this can be used to determine when to train + // model in order to control cost. If not specified: the default value for + // `CreateModel` method is `TRAINING`. The default value for + // `UpdateModel` method is to keep the state the same as before. + TrainingState training_state = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. The serving state of the model: `ACTIVE`, `NOT_ACTIVE`. + ServingState serving_state = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Timestamp the Recommendation Model was created at. + google.protobuf.Timestamp create_time = 5 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Timestamp the Recommendation Model was last updated. E.g. + // if a Recommendation Model was paused - this would be the time the pause was + // initiated. + google.protobuf.Timestamp update_time = 6 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Required. The type of model e.g. `home-page`. + // + // Currently supported values: `recommended-for-you`, `others-you-may-like`, + // `frequently-bought-together`, `page-optimization`, `similar-items`, + // `buy-it-again`, `on-sale-items`, and `recently-viewed`(readonly value). + // + // + // This field together with + // [optimization_objective][google.cloud.retail.v2beta.Model.optimization_objective] + // describe model metadata to use to control model training and serving. + // See https://cloud.google.com/retail/docs/models + // for more details on what the model metadata control and which combination + // of parameters are valid. For invalid combinations of parameters (e.g. type + // = `frequently-bought-together` and optimization_objective = `ctr`), you + // receive an error 400 if you try to create/update a recommendation with + // this set of knobs. + string type = 7 [(google.api.field_behavior) = REQUIRED]; + + // Optional. The optimization objective e.g. `cvr`. + // + // Currently supported + // values: `ctr`, `cvr`, `revenue-per-order`. + // + // If not specified, we choose default based on model type. + // Default depends on type of recommendation: + // + // `recommended-for-you` => `ctr` + // + // `others-you-may-like` => `ctr` + // + // `frequently-bought-together` => `revenue_per_order` + // + // This field together with + // [optimization_objective][google.cloud.retail.v2beta.Model.type] + // describe model metadata to use to control model training and serving. + // See https://cloud.google.com/retail/docs/models + // for more details on what the model metadata control and which combination + // of parameters are valid. For invalid combinations of parameters (e.g. type + // = `frequently-bought-together` and optimization_objective = `ctr`), you + // receive an error 400 if you try to create/update a recommendation with + // this set of knobs. + string optimization_objective = 8 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The state of periodic tuning. + // + // The period we use is 3 months - to do a + // one-off tune earlier use the `TuneModel` method. Default value + // is `PERIODIC_TUNING_ENABLED`. + PeriodicTuningState periodic_tuning_state = 11 + [(google.api.field_behavior) = OPTIONAL]; + + // Output only. The timestamp when the latest successful tune finished. + google.protobuf.Timestamp last_tune_time = 12 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The tune operation associated with the model. + // + // Can be used to determine if there is an ongoing tune for this + // recommendation. Empty field implies no tune is goig on. + string tuning_operation = 15 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The state of data requirements for this model: `DATA_OK` and + // `DATA_ERROR`. + // + // Recommendation model cannot be trained if the data is in + // `DATA_ERROR` state. Recommendation model can have `DATA_ERROR` state even + // if serving state is `ACTIVE`: models were trained successfully before, but + // cannot be refreshed because model no longer has sufficient + // data for training. + DataState data_state = 16 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. If `RECOMMENDATIONS_FILTERING_ENABLED`, recommendation filtering + // by attributes is enabled for the model. + RecommendationsFilteringOption filtering_option = 18 + [(google.api.field_behavior) = OPTIONAL]; + + // Output only. The list of valid serving configs associated with the + // PageOptimizationConfig. + repeated ServingConfigList serving_config_lists = 19 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/model_service.proto b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/model_service.proto new file mode 100644 index 00000000000..0b5c1c4a9f1 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/model_service.proto @@ -0,0 +1,263 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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/model.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "cloud.google.com/go/retail/apiv2beta/retailpb;retailpb"; +option java_multiple_files = true; +option java_outer_classname = "ModelServiceProto"; +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 performing CRUD operations on models. +// Recommendation models contain all the metadata necessary to generate a set of +// models for the `Predict()` API. A model is queried +// indirectly via a ServingConfig, which associates a model with a +// given Placement (e.g. Frequently Bought Together on Home Page). +// +// This service allows you to do the following: +// +// * Initiate training of a model. +// * Pause training of an existing model. +// * List all the available models along with their metadata. +// * Control their tuning schedule. +service ModelService { + option (google.api.default_host) = "retail.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform"; + + // Creates a new model. + rpc CreateModel(CreateModelRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/models" + body: "model" + }; + option (google.api.method_signature) = "parent,model"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2beta.Model" + metadata_type: "google.cloud.retail.v2beta.CreateModelMetadata" + }; + } + + // Gets a model. + rpc GetModel(GetModelRequest) returns (Model) { + option (google.api.http) = { + get: "/v2beta/{name=projects/*/locations/*/catalogs/*/models/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Pauses the training of an existing model. + rpc PauseModel(PauseModelRequest) returns (Model) { + option (google.api.http) = { + post: "/v2beta/{name=projects/*/locations/*/catalogs/*/models/*}:pause" + body: "*" + }; + option (google.api.method_signature) = "name"; + } + + // Resumes the training of an existing model. + rpc ResumeModel(ResumeModelRequest) returns (Model) { + option (google.api.http) = { + post: "/v2beta/{name=projects/*/locations/*/catalogs/*/models/*}:resume" + body: "*" + }; + option (google.api.method_signature) = "name"; + } + + // Deletes an existing model. + rpc DeleteModel(DeleteModelRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v2beta/{name=projects/*/locations/*/catalogs/*/models/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists all the models linked to this event store. + rpc ListModels(ListModelsRequest) returns (ListModelsResponse) { + option (google.api.http) = { + get: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/models" + }; + option (google.api.method_signature) = "parent"; + } + + // Update of model metadata. Only fields that + // currently can be updated are: `filtering_option` and + // `periodic_tuning_state`. + // If other values are provided, this API method ignores them. + rpc UpdateModel(UpdateModelRequest) returns (Model) { + option (google.api.http) = { + patch: "/v2beta/{model.name=projects/*/locations/*/catalogs/*/models/*}" + body: "model" + }; + option (google.api.method_signature) = "model,update_mask"; + } + + // Tunes an existing model. + rpc TuneModel(TuneModelRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v2beta/{name=projects/*/locations/*/catalogs/*/models/*}:tune" + body: "*" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "google.cloud.retail.v2beta.TuneModelResponse" + metadata_type: "google.cloud.retail.v2beta.TuneModelMetadata" + }; + } +} + +// Request for creating a model. +message CreateModelRequest { + // Required. The parent resource under which to create the model. 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 payload of the [Model][google.cloud.retail.v2beta.Model] to + // create. + Model model = 2 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Whether to run a dry run to validate the request (without + // actually creating the model). + bool dry_run = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Request for updating an existing model. +message UpdateModelRequest { + // Required. The body of the updated + // [Model][google.cloud.retail.v2beta.Model]. + Model model = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Indicates which fields in the provided 'model' to + // update. If not set, by default updates all fields. + google.protobuf.FieldMask update_mask = 2 + [(google.api.field_behavior) = OPTIONAL]; +} + +// Request for getting a model. +message GetModelRequest { + // Required. The resource name of the + // [Model][google.cloud.retail.v2beta.Model] to get. Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog}/models/{model_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Model" } + ]; +} + +// Request for pausing training of a model. +message PauseModelRequest { + // Required. The name of the model to pause. + // Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Model" } + ]; +} + +// Request for resuming training of a model. +message ResumeModelRequest { + // Required. The name of the model to resume. + // Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + string name = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for listing models associated with a resource. +message ListModelsRequest { + // Required. The parent for which to list models. + // 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 `ListModels` + // call. Provide this to retrieve the subsequent page. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// Request for deleting a model. +message DeleteModelRequest { + // Required. The resource name of the + // [Model][google.cloud.retail.v2beta.Model] to delete. Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Model" } + ]; +} + +// Response to a ListModelRequest. +message ListModelsResponse { + // List of Models. + repeated Model models = 1; + + // Pagination token, if not returned indicates the last page. + string next_page_token = 2; +} + +// Request to manually start a tuning process now (instead of waiting for +// the periodically scheduled tuning to happen). +message TuneModelRequest { + // Required. The resource name of the model to tune. + // Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "retail.googleapis.com/Model" } + ]; +} + +// Metadata associated with a create operation. +message CreateModelMetadata { + // The resource name of the model that this create applies to. + // Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + string model = 1; +} + +// Metadata associated with a tune operation. +message TuneModelMetadata { + // The resource name of the model that this tune applies to. + // Format: + // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + string model = 1; +} + +// Response associated with a tune operation. +message TuneModelResponse {} diff --git a/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/prediction_service.proto b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/prediction_service.proto new file mode 100644 index 00000000000..ba579bdb7d0 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/prediction_service.proto @@ -0,0 +1,226 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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/user_event.proto"; +import "google/protobuf/struct.proto"; + +option csharp_namespace = "Google.Cloud.Retail.V2Beta"; +option go_package = "cloud.google.com/go/retail/apiv2beta/retailpb;retailpb"; +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: "*" + additional_bindings { + post: "/v2beta/{placement=projects/*/locations/*/catalogs/*/servingConfigs/*}:predict" + body: "*" + } + }; + } +} + +// Request message for Predict method. +message PredictRequest { + // Required. Full resource name of the format: + // `{placement=projects/*/locations/global/catalogs/default_catalog/servingConfigs/*}` + // or + // `{placement=projects/*/locations/global/catalogs/default_catalog/placements/*}`. + // We recommend using the `servingConfigs` resource. `placements` is a legacy + // resource. + // The ID of the Recommendations AI serving config or placement. + // Before you can request predictions from your model, you must create at + // least one serving config or placement for it. For more information, see + // [Manage serving configs] + // (https://cloud.google.com/retail/docs/manage-configs). + // + // The full list of available serving configs can be seen at + // https://console.cloud.google.com/ai/retail/catalogs/default_catalog/configs + 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.v2beta.UserEvent.visitor_id] or + // [UserInfo.user_id][google.cloud.retail.v2beta.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.v2beta.UserEvent.visitor_id] to + // a random unique ID and leave + // [UserInfo.user_id][google.cloud.retail.v2beta.UserInfo.user_id] unset. + UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED]; + + // Maximum number of results to return. 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; + + // This field is not used; leave it unset. + string page_token = 4 [deprecated = true]; + + // 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 *no* + // results. If instead you want empty result sets to return generic + // (unfiltered) popular products, set `strictFiltering` to False in + // `PredictRequest.params`. Note that the API will never return items with + // storageStatus of "EXPIRED" or "DELETED" regardless of filter choices. + // + // If `filterSyntaxV2` is set to true under the `params` field, then + // attribute-based expressions are expected instead of the above described + // tag-based syntax. Examples: + // + // * (colors: ANY("Red", "Blue")) AND NOT (categories: ANY("Phones")) + // * (availability: ANY("IN_STOCK")) AND + // (colors: ANY("Red") OR categories: ANY("Phones")) + // + // For more information, see + // [Filter recommendations](https://cloud.google.com/retail/docs/filter-recs). + 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 a 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. + // * `filterSyntaxV2`: Boolean. False by default. If set to true, the `filter` + // field is interpreteted according to the new, attribute-based syntax. + 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.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/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/product.proto b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/product.proto new file mode 100644 index 00000000000..188635659f8 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/product.proto @@ -0,0 +1,597 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 = "cloud.google.com/go/retail/apiv2beta/retailpb;retailpb"; +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]. + // Note that this is only applicable to + // [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] and + // [Type.COLLECTION][google.cloud.retail.v2beta.Product.Type.COLLECTION], + // and ignored for + // [Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT]. In + // general, we suggest the users to delete the stale products explicitly, + // instead of using this field to determine staleness. + // + // 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. Note that this is only + // applicable to + // [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] and + // [Type.COLLECTION][google.cloud.retail.v2beta.Product.Type.COLLECTION], + // and ignored for + // [Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT]. In + // general, we suggest the users to delete the stale products explicitly, + // instead of using this field to determine staleness. + // + // 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 + // an 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, 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]. + // Note that this is only applicable to + // [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] and + // [Type.COLLECTION][google.cloud.retail.v2beta.Product.Type.COLLECTION], and + // ignored for + // [Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT]. + 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] + // + // The maximum number of paths is 30. Otherwise, an INVALID_ARGUMENT error is + // returned. + // + // Note: Returning more fields in + // [SearchResponse][google.cloud.retail.v2beta.SearchResponse] can increase + // response payload size and serving latency. + // + // This field is deprecated. Use the retrievable site-wide control instead. + google.protobuf.FieldMask retrievable_fields = 30 [deprecated = true]; + + // 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]; + + // Output only. A list of local inventories specific to different places. + // + // This field can be managed by + // [ProductService.AddLocalInventories][google.cloud.retail.v2beta.ProductService.AddLocalInventories] + // and + // [ProductService.RemoveLocalInventories][google.cloud.retail.v2beta.ProductService.RemoveLocalInventories] + // APIs if fine-grained, high-volume updates are necessary. + repeated LocalInventory local_inventories = 35 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/product_service.proto b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/product_service.proto new file mode 100644 index 00000000000..edf21245404 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/product_service.proto @@ -0,0 +1,925 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 = "cloud.google.com/go/retail/apiv2beta/retailpb;retailpb"; +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. + // 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 is 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 + // [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] + // or + // [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. + // + // When inventory is updated with + // [ProductService.CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] + // and + // [ProductService.UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct], + // the specified inventory field value(s) overwrite any existing value(s) + // while ignoring the last update time for this field. Furthermore, the last + // update times for the specified inventory fields are overwritten by the + // times of the + // [ProductService.CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] + // or + // [ProductService.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 is used. + // + // If no inventory fields are set in + // [SetInventoryRequest.set_mask][google.cloud.retail.v2beta.SetInventoryRequest.set_mask], + // then any existing inventory information is preserved. + // + // Pre-existing inventory information can only be updated with + // [ProductService.SetInventory][google.cloud.retail.v2beta.ProductService.SetInventory], + // [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.AddFulfillmentPlaces], + // and + // [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces]. + // + // The returned [Operation][google.longrunning.Operation]s is obsolete after + // one day, and the [GetOperation][google.longrunning.Operations.GetOperation] + // API returns `NOT_FOUND` afterwards. + // + // If conflicting updates are issued, the + // [Operation][google.longrunning.Operation]s associated with the stale + // updates are not marked as [done][google.longrunning.Operation.done] until + // they are obsolete. + 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" + }; + } + + // It is recommended to use the + // [ProductService.AddLocalInventories][google.cloud.retail.v2beta.ProductService.AddLocalInventories] + // method instead of + // [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.AddFulfillmentPlaces]. + // [ProductService.AddLocalInventories][google.cloud.retail.v2beta.ProductService.AddLocalInventories] + // achieves the same results but provides more fine-grained control over + // ingesting local inventory data. + // + // 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 + // [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] + // or + // [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. + // + // The returned [Operation][google.longrunning.Operation]s will be obsolete + // after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] + // API will return NOT_FOUND afterwards. + // + // If conflicting updates are issued, the + // [Operation][google.longrunning.Operation]s associated with the stale + // updates will not be marked as [done][google.longrunning.Operation.done] + // until being obsolete. + 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" + }; + } + + // It is recommended to use the + // [ProductService.RemoveLocalInventories][google.cloud.retail.v2beta.ProductService.RemoveLocalInventories] + // method instead of + // [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces]. + // [ProductService.RemoveLocalInventories][google.cloud.retail.v2beta.ProductService.RemoveLocalInventories] + // achieves the same results but provides more fine-grained control over + // ingesting local inventory data. + // + // 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 + // [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] + // or + // [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. + // + // The returned [Operation][google.longrunning.Operation]s will be obsolete + // after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] + // API will return NOT_FOUND afterwards. + // + // If conflicting updates are issued, the + // [Operation][google.longrunning.Operation]s associated with the stale + // updates will not be marked as [done][google.longrunning.Operation.done] + // until being obsolete. + 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 + // [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] + // or + // [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. + // + // Local inventory information can only be modified using this method. + // [ProductService.CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] + // and + // [ProductService.UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct] + // has no effect on local inventories. + // + // The returned [Operation][google.longrunning.Operation]s will be obsolete + // after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] + // API will return NOT_FOUND afterwards. + // + // If conflicting updates are issued, the + // [Operation][google.longrunning.Operation]s associated with the stale + // updates will not be marked as [done][google.longrunning.Operation.done] + // until being obsolete. + 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 + // [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] + // or + // [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. + // + // Local inventory information can only be removed using this method. + // [ProductService.CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] + // and + // [ProductService.UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct] + // has no effect on local inventories. + // + // The returned [Operation][google.longrunning.Operation]s will be obsolete + // after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] + // API will return NOT_FOUND afterwards. + // + // If conflicting updates are issued, the + // [Operation][google.longrunning.Operation]s associated with the stale + // updates will not be marked as [done][google.longrunning.Operation.done] + // until being obsolete. + 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 +// [ProductService.CreateProduct][google.cloud.retail.v2beta.ProductService.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 +// [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.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 +// [ProductService.UpdateProduct][google.cloud.retail.v2beta.ProductService.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. + // + // 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.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 +// [ProductService.DeleteProduct][google.cloud.retail.v2beta.ProductService.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 +// [ProductService.SetInventory][google.cloud.retail.v2beta.ProductService.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][google.cloud.retail.v2beta.Product.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][google.cloud.retail.v2beta.Product.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][google.cloud.retail.v2beta.Product.fulfillment_info] + // * Checks that only the desired fulfillment info types have empty + // [SetInventoryRequest.inventory.fulfillment_info.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.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, + // [ProductService.UpdateProduct][google.cloud.retail.v2beta.ProductService.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 +// [ProductService.SetInventory][google.cloud.retail.v2beta.ProductService.SetInventory] +// method. +message SetInventoryMetadata {} + +// Response of the SetInventoryRequest. Currently empty because +// there is no meaningful response populated from the +// [ProductService.SetInventory][google.cloud.retail.v2beta.ProductService.SetInventory] +// method. +message SetInventoryResponse {} + +// Request message for +// [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.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][google.cloud.retail.v2beta.FulfillmentInfo.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 +// [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2beta.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.v2beta.ProductService.AddFulfillmentPlaces] +// method. +message AddFulfillmentPlacesResponse {} + +// Request message for +// [ProductService.AddLocalInventories][google.cloud.retail.v2beta.ProductService.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 +// [ProductService.AddLocalInventories][google.cloud.retail.v2beta.ProductService.AddLocalInventories] +// method. +message AddLocalInventoriesMetadata {} + +// Response of the +// [ProductService.AddLocalInventories][google.cloud.retail.v2beta.ProductService.AddLocalInventories] +// API. Currently empty because there is no meaningful response populated from +// the +// [ProductService.AddLocalInventories][google.cloud.retail.v2beta.ProductService.AddLocalInventories] +// method. +message AddLocalInventoriesResponse {} + +// Request message for +// [ProductService.RemoveLocalInventories][google.cloud.retail.v2beta.ProductService.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 +// [ProductService.RemoveLocalInventories][google.cloud.retail.v2beta.ProductService.RemoveLocalInventories] +// method. +message RemoveLocalInventoriesMetadata {} + +// Response of the +// [ProductService.RemoveLocalInventories][google.cloud.retail.v2beta.ProductService.RemoveLocalInventories] +// API. Currently empty because there is no meaningful response populated from +// the +// [ProductService.RemoveLocalInventories][google.cloud.retail.v2beta.ProductService.RemoveLocalInventories] +// method. +message RemoveLocalInventoriesResponse {} + +// Request message for +// [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.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][google.cloud.retail.v2beta.FulfillmentInfo.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 +// [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces] +// method. +message RemoveFulfillmentPlacesMetadata {} + +// Response of the RemoveFulfillmentPlacesRequest. Currently empty because there +// is no meaningful response populated from the +// [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces] +// method. +message RemoveFulfillmentPlacesResponse {} diff --git a/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/promotion.proto b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/promotion.proto new file mode 100644 index 00000000000..e388f3aeb7a --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/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 = "cloud.google.com/go/retail/apiv2beta/retailpb;retailpb"; +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/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/purge_config.proto b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/purge_config.proto new file mode 100644 index 00000000000..377c465499a --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/purge_config.proto @@ -0,0 +1,83 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 = "cloud.google.com/go/retail/apiv2beta/retailpb;retailpb"; +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, + (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.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/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/search_service.proto b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/search_service.proto new file mode 100644 index 00000000000..efd7fc27e48 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/search_service.proto @@ -0,0 +1,990 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 = "cloud.google.com/go/retail/apiv2beta/retailpb;retailpb"; +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"; +option (google.api.resource_definition) = { + type: "retail.googleapis.com/Experiment" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/experiments/{experiment}" +}; + +// Service for search. +// +// This feature is only available for users who have Retail Search enabled. +// 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. + // 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: "*" + additional_bindings { + post: "/v2beta/{placement=projects/*/locations/*/catalogs/*/servingConfigs/*}: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 40. + // + // For all numerical facet keys that appear in the list of products from + // the catalog, the percentiles 0, 10, 30, 50, 70, 90 and 100 are + // computed from their distribution weekly. If the model assigns a high + // score to a numerical facet key and its intervals are not specified in + // the search request, these percentiles will become the bounds + // for its intervals and will be returned in the response. If the + // facet key intervals are specified in the request, then the specified + // intervals will be returned instead. + 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; + + // True to make facet keys case insensitive when getting faceting + // values with prefixes or contains; false otherwise. + bool case_insensitive = 10; + + // The order in which + // [SearchResponse.Facet.values][google.cloud.retail.v2beta.SearchResponse.Facet.values] + // are returned. + // + // Allowed values are: + // + // * "count desc", which means order by + // [SearchResponse.Facet.values.count][google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue.count] + // descending. + // + // * "value desc", which means order by + // [SearchResponse.Facet.values.value][google.cloud.retail.v2beta.SearchResponse.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, + // [SearchResponse.Facet.values.value][google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue.value] + // will be always "1" and + // [SearchResponse.Facet.values.count][google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue.count] + // will be the number of results that match 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; + + // Returns the min and max value for each numerical facet intervals. + // Ignored for textual facets. + bool return_min_max = 11; + } + + // 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 50. 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. + // + // 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.v2beta.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.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 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.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. In this case, server behavior + // 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. In this case, server behavior defaults to + // [Mode.AUTO][google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.Mode.AUTO]. + MODE_UNSPECIFIED = 0; + + // Let CRS decide whether to use personalization based on quality of user + // event data. + AUTO = 1; + + // Disable personalization. + DISABLED = 2; + } + + // Defaults to + // [Mode.AUTO][google.cloud.retail.v2beta.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. In this case, server behavior + // defaults to + // [Mode.AUTO][google.cloud.retail.v2beta.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.v2beta.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.v2beta.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][google.cloud.retail.v2beta.SearchResponse.SearchResult] + // and + // [SearchResponse.Facet][google.cloud.retail.v2beta.SearchResponse.Facet] + // will be returned. + SEARCH_MODE_UNSPECIFIED = 0; + + // Only product search will be performed. The faceted search will be + // disabled. + // + // Only + // [SearchResponse.SearchResult][google.cloud.retail.v2beta.SearchResponse.SearchResult] + // will be returned. + // [SearchResponse.Facet][google.cloud.retail.v2beta.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_specs][google.cloud.retail.v2beta.SearchRequest.facet_specs] + // 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][google.cloud.retail.v2beta.SearchResponse.Facet] + // will be returned. + // [SearchResponse.SearchResult][google.cloud.retail.v2beta.SearchResponse.SearchResult] + // will not be returned. + FACETED_SEARCH_ONLY = 2; + } + + // Required. The resource name of the Retail Search serving config, such as + // `projects/*/locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` + // or the name of the legacy placement resource, such as + // `projects/*/locations/global/catalogs/default_catalog/placements/default_search`. + // This field is used to identify the serving config 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.v2beta.SearchRequest.filter] and + // [page_categories][google.cloud.retail.v2beta.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.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 200 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][google.cloud.retail.v2beta.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.local_inventories.attributes][google.cloud.retail.v2beta.LocalInventory.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. Must be set 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, 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. + // + // Notice that if both + // [ServingConfig.personalization_spec][google.cloud.retail.v2beta.ServingConfig.personalization_spec] + // and + // [SearchRequest.personalization_spec][google.cloud.retail.v2beta.SearchRequest.personalization_spec] + // are set. + // [SearchRequest.personalization_spec][google.cloud.retail.v2beta.SearchRequest.personalization_spec] + // will override + // [ServingConfig.personalization_spec][google.cloud.retail.v2beta.ServingConfig.personalization_spec]. + 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; + + // The entity for customers that may run multiple different entities, domains, + // sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, + // `google.com`, `youtube.com`, etc. + // If this is set, it should be exactly matched with + // [UserEvent.entity][google.cloud.retail.v2beta.UserEvent.entity] to get + // search results boosted by entity. + string entity = 38; +} + +// 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; + + // Specifies previous events related to this product for this user based on + // [UserEvent][google.cloud.retail.v2beta.UserEvent] with same + // [SearchRequest.visitor_id][google.cloud.retail.v2beta.SearchRequest.visitor_id] + // or [UserInfo.user_id][google.cloud.retail.v2beta.UserInfo.user_id]. + // + // This is set only when + // [SearchRequest.PersonalizationSpec.mode][google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.mode] + // is + // [SearchRequest.PersonalizationSpec.Mode.AUTO][google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.Mode.AUTO]. + // + // Possible values: + // + // * `purchased`: Indicates that this product has been purchased before. + repeated string personal_labels = 7; + } + + // 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 minimum value in the + // [FacetValue.interval][google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue.interval]. + // Only supported on numerical facets and returned if + // [SearchRequest.FacetSpec.FacetKey.return_min_max][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.return_min_max] + // is true. + double min_value = 5; + + // The maximum value in the + // [FacetValue.interval][google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue.interval]. + // Only supported on numerical facets and returned if + // [SearchRequest.FacetSpec.FacetKey.return_min_max][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.return_min_max] + // is true. + double max_value = 6; + } + + // 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; + + // 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 is used for search. + 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 is performed, and only + // [redirect_uri][google.cloud.retail.v2beta.SearchResponse.redirect_uri] and + // [attribution_token][google.cloud.retail.v2beta.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.v2beta.SearchRequest.BoostSpec.condition_boost_specs] + // that are not applied during serving. + repeated SearchRequest.BoostSpec.ConditionBoostSpec + invalid_condition_boost_specs = 14; + + // Metadata related to A/B testing [Experiment][] associated with this + // response. Only exists when an experiment is triggered. + repeated ExperimentInfo experiment_info = 17; +} + +// Metadata for active A/B testing [Experiments][]. +message ExperimentInfo { + // Metadata for active serving config A/B tests. + message ServingConfigExperiment { + // The fully qualified resource name of the original + // [SearchRequest.placement][google.cloud.retail.v2beta.SearchRequest.placement] + // in the search request prior to reassignment by experiment API. For + // example: `projects/*/locations/*/catalogs/*/servingConfigs/*`. + string original_serving_config = 1 [(google.api.resource_reference) = { + type: "retail.googleapis.com/ServingConfig" + }]; + + // The fully qualified resource name of the serving config + // [VariantArm.serving_config_id][] responsible for generating the search + // response. For example: + // `projects/*/locations/*/catalogs/*/servingConfigs/*`. + string experiment_serving_config = 2 [(google.api.resource_reference) = { + type: "retail.googleapis.com/ServingConfig" + }]; + } + + // Information associated with the specific experiment entity being recorded. + oneof experiment_metadata { + // A/B test between existing Cloud Retail Search + // [ServingConfig][google.cloud.retail.v2beta.ServingConfig]s. + ServingConfigExperiment serving_config_experiment = 2; + } + + // The fully qualified resource name of the experiment that provides the + // serving config under test, should an active experiment exist. For example: + // `projects/*/locations/global/catalogs/default_catalog/experiments/experiment_id` + string experiment = 1 [(google.api.resource_reference) = { + type: "retail.googleapis.com/Experiment" + }]; +} diff --git a/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/serving_config.proto b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/serving_config.proto new file mode 100644 index 00000000000..45dd103f9c7 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/serving_config.proto @@ -0,0 +1,281 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 = "cloud.google.com/go/retail/apiv2beta/retailpb;retailpb"; +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). +message ServingConfig { + option (google.api.resource) = { + type: "retail.googleapis.com/ServingConfig" + pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}" + }; + + // What type of diversity - data or rule based. + enum DiversityType { + // Default value. + DIVERSITY_TYPE_UNSPECIFIED = 0; + + // Rule based diversity. + RULE_BASED_DIVERSITY = 2; + + // Data driven diversity. + DATA_DRIVEN_DIVERSITY = 3; + } + + // 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 in the same + // [Catalog][google.cloud.retail.v2beta.Catalog] 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-reranking` + // * `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][google.cloud.retail.v2beta.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; + + // What kind of diversity to use - data driven or rule based. If unset, the + // server behavior defaults to + // [RULE_BASED_DIVERSITY][google.cloud.retail.v2beta.ServingConfig.DiversityType.RULE_BASED_DIVERSITY]. + DiversityType diversity_type = 20; + + // 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; + + // The specification for personalization spec. + // + // 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]. + // + // Notice that if both + // [ServingConfig.personalization_spec][google.cloud.retail.v2beta.ServingConfig.personalization_spec] + // and + // [SearchRequest.personalization_spec][google.cloud.retail.v2beta.SearchRequest.personalization_spec] + // are set. + // [SearchRequest.personalization_spec][google.cloud.retail.v2beta.SearchRequest.personalization_spec] + // will override + // [ServingConfig.personalization_spec][google.cloud.retail.v2beta.ServingConfig.personalization_spec]. + SearchRequest.PersonalizationSpec personalization_spec = 21; + + // 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/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/serving_config_service.proto b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/serving_config_service.proto new file mode 100644 index 00000000000..66b210b3ab1 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/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 = "cloud.google.com/go/retail/apiv2beta/retailpb;retailpb"; +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/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/user_event.proto b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/user_event.proto new file mode 100644 index 00000000000..c212b9de242 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/user_event.proto @@ -0,0 +1,352 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 = "cloud.google.com/go/retail/apiv2beta/retailpb;retailpb"; +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. + // + // 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.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 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.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, 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; + + // The entity for customers that may run multiple different entities, domains, + // sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, + // `google.com`, `youtube.com`, etc. + // It is recommended to set this field to get better per-entity search, + // completion and prediction results. + string entity = 23; +} + +// 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/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/user_event_service.proto b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/user_event_service.proto new file mode 100644 index 00000000000..d6a9b0e6016 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/user_event_service.proto @@ -0,0 +1,210 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY 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 = "cloud.google.com/go/retail/apiv2beta/retailpb;retailpb"; +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 + // are not annotated with detailed product information for products that are + // missing from the catalog when the user event is ingested. These + // events are stored as unjoined events with limited usage on training and + // serving. You can use this method to start a join operation on specified + // events with the latest version of product catalog. You can also use this + // method 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]; + + // If set to true, the user event will be written asynchronously after + // validation, and the API will respond without waiting for the write. + // Therefore, silent failures can occur even if the API returns success. In + // case of silent failures, error messages can be found in Stackdriver logs. + bool write_async = 3; +} + +// Request message for CollectUserEvent method. +message CollectUserEventRequest { + // The rule that can convert the raw_json to a user event. It is needed + // only when the raw_json is set. + oneof conversion_rule { + // The prebuilt rule name that can convert a specific type of raw_json. + // For example: "ga4_bq" rule for the GA4 user event schema. + string prebuilt_rule = 6; + } + + // 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; + + // An arbitrary serialized JSON string that contains necessary information + // that can comprise a user event. When this field is specified, the + // user_event field will be ignored. Note: line-delimited JSON is not + // supported, a single JSON only. + string raw_json = 5; +} + +// 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/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.add_catalog_attribute.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.add_catalog_attribute.js new file mode 100644 index 00000000000..5e4c695ad60 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.add_catalog_attribute.js @@ -0,0 +1,68 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.batch_remove_catalog_attributes.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.batch_remove_catalog_attributes.js new file mode 100644 index 00000000000..1b022e70542 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.batch_remove_catalog_attributes.js @@ -0,0 +1,70 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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, attributeKeys) { + // [START retail_v2beta_generated_CatalogService_BatchRemoveCatalogAttributes_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The attributes config resource shared by all catalog attributes + * being deleted. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` + */ + // const attributesConfig = 'abc123' + /** + * Required. The attribute name keys of the + * CatalogAttribute google.cloud.retail.v2beta.CatalogAttribute s to delete. + * A maximum of 1000 catalog attributes can be deleted in a batch. + */ + // const attributeKeys = 'abc123' + + // Imports the Retail library + const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new CatalogServiceClient(); + + async function callBatchRemoveCatalogAttributes() { + // Construct request + const request = { + attributesConfig, + attributeKeys, + }; + + // Run request + const response = await retailClient.batchRemoveCatalogAttributes(request); + console.log(response); + } + + callBatchRemoveCatalogAttributes(); + // [END retail_v2beta_generated_CatalogService_BatchRemoveCatalogAttributes_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.get_attributes_config.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.get_attributes_config.js new file mode 100644 index 00000000000..83a8ed770fe --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.get_attributes_config.js @@ -0,0 +1,62 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.get_completion_config.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.get_completion_config.js new file mode 100644 index 00000000000..2b9350d8058 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.get_completion_config.js @@ -0,0 +1,62 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.get_default_branch.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.get_default_branch.js new file mode 100644 index 00000000000..111b3ffe60e --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.get_default_branch.js @@ -0,0 +1,61 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.list_catalogs.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.list_catalogs.js new file mode 100644 index 00000000000..64a3f18de45 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.list_catalogs.js @@ -0,0 +1,86 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.remove_catalog_attribute.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.remove_catalog_attribute.js new file mode 100644 index 00000000000..b453231d24d --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.remove_catalog_attribute.js @@ -0,0 +1,68 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.replace_catalog_attribute.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.replace_catalog_attribute.js new file mode 100644 index 00000000000..e3802ca5272 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.replace_catalog_attribute.js @@ -0,0 +1,76 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.set_default_branch.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.set_default_branch.js new file mode 100644 index 00000000000..094ae12bc02 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.set_default_branch.js @@ -0,0 +1,84 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.update_attributes_config.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.update_attributes_config.js new file mode 100644 index 00000000000..2da5b62268c --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.update_attributes_config.js @@ -0,0 +1,70 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.update_catalog.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.update_catalog.js new file mode 100644 index 00000000000..ff13c43501e --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.update_catalog.js @@ -0,0 +1,73 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.update_completion_config.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.update_completion_config.js new file mode 100644 index 00000000000..1eb92415ea6 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.update_completion_config.js @@ -0,0 +1,78 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2beta/samples/generated/v2beta/completion_service.complete_query.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/completion_service.complete_query.js new file mode 100644 index 00000000000..ebb8fe33588 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/completion_service.complete_query.js @@ -0,0 +1,132 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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' + /** + * Note that this field applies for `user-data` dataset only. For requests + * with `cloud-retail` dataset, setting this field has no effect. + * 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. We recommend that you + * leave this field empty. + * It can 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 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 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 + /** + * The entity for customers that may run multiple different entities, domains, + * sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, + * `google.com`, `youtube.com`, etc. + * If this is set, it should be exactly matched with + * UserEvent.entity google.cloud.retail.v2beta.UserEvent.entity to get + * per-entity autocomplete results. + */ + // const entity = 'abc123' + + // 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/google-cloud-retail/v2beta/samples/generated/v2beta/completion_service.import_completion_data.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/completion_service.import_completion_data.js new file mode 100644 index 00000000000..6d1469d212d --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/completion_service.import_completion_data.js @@ -0,0 +1,76 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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 is sent to + * specified Pub/Sub topic. The message data is 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/google-cloud-retail/v2beta/samples/generated/v2beta/control_service.create_control.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/control_service.create_control.js new file mode 100644 index 00000000000..227139e6cc9 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/control_service.create_control.js @@ -0,0 +1,75 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2beta/samples/generated/v2beta/control_service.delete_control.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/control_service.delete_control.js new file mode 100644 index 00000000000..ffa79ce76ae --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/control_service.delete_control.js @@ -0,0 +1,62 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the 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/google-cloud-retail/v2beta/samples/generated/v2beta/control_service.get_control.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/control_service.get_control.js new file mode 100644 index 00000000000..0c0cccc9269 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/control_service.get_control.js @@ -0,0 +1,62 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the Control to get. 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/google-cloud-retail/v2beta/samples/generated/v2beta/control_service.list_controls.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/control_service.list_controls.js new file mode 100644 index 00000000000..e690fb51cee --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/control_service.list_controls.js @@ -0,0 +1,82 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2beta/samples/generated/v2beta/control_service.update_control.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/control_service.update_control.js new file mode 100644 index 00000000000..25d7ee12766 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/control_service.update_control.js @@ -0,0 +1,69 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.create_model.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.create_model.js new file mode 100644 index 00000000000..2ab35505f85 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.create_model.js @@ -0,0 +1,74 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, model) { + // [START retail_v2beta_generated_ModelService_CreateModel_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent resource under which to create the model. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + */ + // const parent = 'abc123' + /** + * Required. The payload of the Model google.cloud.retail.v2beta.Model to + * create. + */ + // const model = {} + /** + * Optional. Whether to run a dry run to validate the request (without + * actually creating the model). + */ + // const dryRun = true + + // Imports the Retail library + const {ModelServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ModelServiceClient(); + + async function callCreateModel() { + // Construct request + const request = { + parent, + model, + }; + + // Run request + const [operation] = await retailClient.createModel(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateModel(); + // [END retail_v2beta_generated_ModelService_CreateModel_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.delete_model.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.delete_model.js new file mode 100644 index 00000000000..2e2163f51e7 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.delete_model.js @@ -0,0 +1,63 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by 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_ModelService_DeleteModel_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the + * Model google.cloud.retail.v2beta.Model to delete. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + */ + // const name = 'abc123' + + // Imports the Retail library + const {ModelServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ModelServiceClient(); + + async function callDeleteModel() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.deleteModel(request); + console.log(response); + } + + callDeleteModel(); + // [END retail_v2beta_generated_ModelService_DeleteModel_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.get_model.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.get_model.js new file mode 100644 index 00000000000..a5439a36581 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.get_model.js @@ -0,0 +1,63 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by 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_ModelService_GetModel_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the + * Model google.cloud.retail.v2beta.Model to get. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog}/models/{model_id}` + */ + // const name = 'abc123' + + // Imports the Retail library + const {ModelServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ModelServiceClient(); + + async function callGetModel() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.getModel(request); + console.log(response); + } + + callGetModel(); + // [END retail_v2beta_generated_ModelService_GetModel_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.list_models.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.list_models.js new file mode 100644 index 00000000000..63a8d86deb5 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.list_models.js @@ -0,0 +1,75 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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_ModelService_ListModels_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent for which to list models. + * 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 `ListModels` + * call. Provide this to retrieve the subsequent page. + */ + // const pageToken = 'abc123' + + // Imports the Retail library + const {ModelServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ModelServiceClient(); + + async function callListModels() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await retailClient.listModelsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListModels(); + // [END retail_v2beta_generated_ModelService_ListModels_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.pause_model.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.pause_model.js new file mode 100644 index 00000000000..3b0f9375fda --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.pause_model.js @@ -0,0 +1,63 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by 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_ModelService_PauseModel_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the model to pause. + * Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + */ + // const name = 'abc123' + + // Imports the Retail library + const {ModelServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ModelServiceClient(); + + async function callPauseModel() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.pauseModel(request); + console.log(response); + } + + callPauseModel(); + // [END retail_v2beta_generated_ModelService_PauseModel_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.resume_model.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.resume_model.js new file mode 100644 index 00000000000..e045255bf49 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.resume_model.js @@ -0,0 +1,63 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by 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_ModelService_ResumeModel_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the model to resume. + * Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + */ + // const name = 'abc123' + + // Imports the Retail library + const {ModelServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ModelServiceClient(); + + async function callResumeModel() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await retailClient.resumeModel(request); + console.log(response); + } + + callResumeModel(); + // [END retail_v2beta_generated_ModelService_ResumeModel_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.tune_model.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.tune_model.js new file mode 100644 index 00000000000..94ff8952158 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.tune_model.js @@ -0,0 +1,64 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by 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_ModelService_TuneModel_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the model to tune. + * Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` + */ + // const name = 'abc123' + + // Imports the Retail library + const {ModelServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ModelServiceClient(); + + async function callTuneModel() { + // Construct request + const request = { + name, + }; + + // Run request + const [operation] = await retailClient.tuneModel(request); + const [response] = await operation.promise(); + console.log(response); + } + + callTuneModel(); + // [END retail_v2beta_generated_ModelService_TuneModel_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.update_model.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.update_model.js new file mode 100644 index 00000000000..4739e4868a2 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.update_model.js @@ -0,0 +1,67 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(model) { + // [START retail_v2beta_generated_ModelService_UpdateModel_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The body of the updated + * Model google.cloud.retail.v2beta.Model. + */ + // const model = {} + /** + * Optional. Indicates which fields in the provided 'model' to + * update. If not set, by default updates all fields. + */ + // const updateMask = {} + + // Imports the Retail library + const {ModelServiceClient} = require('@google-cloud/retail').v2beta; + + // Instantiates a client + const retailClient = new ModelServiceClient(); + + async function callUpdateModel() { + // Construct request + const request = { + model, + }; + + // Run request + const response = await retailClient.updateModel(request); + console.log(response); + } + + callUpdateModel(); + // [END retail_v2beta_generated_ModelService_UpdateModel_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/prediction_service.predict.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/prediction_service.predict.js new file mode 100644 index 00000000000..f0c9bf0bcf5 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/prediction_service.predict.js @@ -0,0 +1,187 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. Full resource name of the format: + * `{placement=projects/* /locations/global/catalogs/default_catalog/servingConfigs/*}` + * or + * `{placement=projects/* /locations/global/catalogs/default_catalog/placements/*}`. + * We recommend using the `servingConfigs` resource. `placements` is a legacy + * resource. + * The ID of the Recommendations AI serving config or placement. + * Before you can request predictions from your model, you must create at + * least one serving config or placement for it. For more information, see + * Manage serving configs + * (https://cloud.google.com/retail/docs/manage-configs). + * The full list of available serving configs can be seen at + * https://console.cloud.google.com/ai/retail/catalogs/default_catalog/configs + */ + // 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.v2beta.UserEvent.visitor_id or + * UserInfo.user_id google.cloud.retail.v2beta.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.v2beta.UserEvent.visitor_id to + * a random unique ID and leave + * UserInfo.user_id google.cloud.retail.v2beta.UserInfo.user_id unset. + */ + // const userEvent = {} + /** + * Maximum number of results to return. 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 + /** + * This field is not used; leave it unset. + */ + // 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 *no* + * results. If instead you want empty result sets to return generic + * (unfiltered) popular products, set `strictFiltering` to False in + * `PredictRequest.params`. Note that the API will never return items with + * storageStatus of "EXPIRED" or "DELETED" regardless of filter choices. + * If `filterSyntaxV2` is set to true under the `params` field, then + * attribute-based expressions are expected instead of the above described + * tag-based syntax. Examples: + * * (colors: ANY("Red", "Blue")) AND NOT (categories: ANY("Phones")) + * * (availability: ANY("IN_STOCK")) AND + * (colors: ANY("Red") OR categories: ANY("Phones")) + * For more information, see + * Filter recommendations (https://cloud.google.com/retail/docs/filter-recs). + */ + // 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 a 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. + * * `filterSyntaxV2`: Boolean. False by default. If set to true, the `filter` + * field is interpreteted according to the new, attribute-based syntax. + */ + // 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/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.add_fulfillment_places.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.add_fulfillment_places.js new file mode 100644 index 00000000000..58f6e51f2af --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.add_fulfillment_places.js @@ -0,0 +1,119 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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 google.cloud.retail.v2beta.FulfillmentInfo.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/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.add_local_inventories.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.add_local_inventories.js new file mode 100644 index 00000000000..bb414c8239c --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.add_local_inventories.js @@ -0,0 +1,103 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.create_product.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.create_product.js new file mode 100644 index 00000000000..c679daa8f4b --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.create_product.js @@ -0,0 +1,83 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent 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/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.delete_product.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.delete_product.js new file mode 100644 index 00000000000..7f4ad6857bf --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.delete_product.js @@ -0,0 +1,78 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.get_product.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.get_product.js new file mode 100644 index 00000000000..5c560a26297 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.get_product.js @@ -0,0 +1,68 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.import_products.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.import_products.js new file mode 100644 index 00000000000..7e782bcf518 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.import_products.js @@ -0,0 +1,98 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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, all fields are updated. + */ + // 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 = {} + /** + * Full Pub/Sub topic name for receiving notification. If this field is set, + * when the import is finished, a notification is sent to + * specified Pub/Sub topic. The message data is 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.v2beta.ImportProductsRequest.parent. + * Make sure that `service-@gcp-sa-retail.iam.gserviceaccount.com` has the + * `pubsub.topics.publish` IAM permission on the topic. + */ + // 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/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.list_products.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.list_products.js new file mode 100644 index 00000000000..4fb5552ed46 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.list_products.js @@ -0,0 +1,135 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent 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/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.remove_fulfillment_places.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.remove_fulfillment_places.js new file mode 100644 index 00000000000..1e7936544cf --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.remove_fulfillment_places.js @@ -0,0 +1,115 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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 google.cloud.retail.v2beta.FulfillmentInfo.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/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.remove_local_inventories.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.remove_local_inventories.js new file mode 100644 index 00000000000..24da928bae0 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.remove_local_inventories.js @@ -0,0 +1,88 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.set_inventory.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.set_inventory.js new file mode 100644 index 00000000000..42222a34431 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.set_inventory.js @@ -0,0 +1,131 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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 google.cloud.retail.v2beta.Product.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 google.cloud.retail.v2beta.Product.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 google.cloud.retail.v2beta.Product.fulfillment_info + * * Checks that only the desired fulfillment info types have empty + * SetInventoryRequest.inventory.fulfillment_info.place_ids google.cloud.retail.v2beta.FulfillmentInfo.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, + * ProductService.UpdateProduct google.cloud.retail.v2beta.ProductService.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/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.update_product.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.update_product.js new file mode 100644 index 00000000000..1c302af33bb --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.update_product.js @@ -0,0 +1,87 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The product 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. + * 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.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/google-cloud-retail/v2beta/samples/generated/v2beta/search_service.search.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/search_service.search.js new file mode 100644 index 00000000000..a413ab297da --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/search_service.search.js @@ -0,0 +1,312 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the Retail Search serving config, such as + * `projects/* /locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` + * or the name of the legacy placement resource, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. + * This field is used to identify the serving config 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.v2beta.SearchRequest.filter and + * page_categories google.cloud.retail.v2beta.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.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 200 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 google.cloud.retail.v2beta.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.local_inventories.attributes google.cloud.retail.v2beta.LocalInventory.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. Must be set 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, 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. + * Notice that if both + * ServingConfig.personalization_spec google.cloud.retail.v2beta.ServingConfig.personalization_spec + * and + * SearchRequest.personalization_spec google.cloud.retail.v2beta.SearchRequest.personalization_spec + * are set. + * SearchRequest.personalization_spec google.cloud.retail.v2beta.SearchRequest.personalization_spec + * will override + * ServingConfig.personalization_spec google.cloud.retail.v2beta.ServingConfig.personalization_spec. + */ + // 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 = {} + /** + * The entity for customers that may run multiple different entities, domains, + * sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, + * `google.com`, `youtube.com`, etc. + * If this is set, it should be exactly matched with + * UserEvent.entity google.cloud.retail.v2beta.UserEvent.entity to get + * search results boosted by entity. + */ + // const entity = 'abc123' + + // 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/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.add_control.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.add_control.js new file mode 100644 index 00000000000..1ab65c31508 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.add_control.js @@ -0,0 +1,68 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.create_serving_config.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.create_serving_config.js new file mode 100644 index 00000000000..46fae64ce42 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.create_serving_config.js @@ -0,0 +1,75 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.delete_serving_config.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.delete_serving_config.js new file mode 100644 index 00000000000..4544ae252d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.delete_serving_config.js @@ -0,0 +1,62 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the 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/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.get_serving_config.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.get_serving_config.js new file mode 100644 index 00000000000..1ea818c54e2 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.get_serving_config.js @@ -0,0 +1,62 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the 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/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.list_serving_configs.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.list_serving_configs.js new file mode 100644 index 00000000000..bbcda9947ba --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.list_serving_configs.js @@ -0,0 +1,75 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.remove_control.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.remove_control.js new file mode 100644 index 00000000000..7009be17e3d --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.remove_control.js @@ -0,0 +1,68 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.update_serving_config.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.update_serving_config.js new file mode 100644 index 00000000000..5e2aa38f5a1 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.update_serving_config.js @@ -0,0 +1,69 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2beta/samples/generated/v2beta/snippet_metadata.google.cloud.retail.v2beta.json b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/snippet_metadata.google.cloud.retail.v2beta.json new file mode 100644 index 00000000000..e64b2a33b6f --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/snippet_metadata.google.cloud.retail.v2beta.json @@ -0,0 +1,2543 @@ +{ + "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": 78, + "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": 65, + "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": 76, + "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": 53, + "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": 54, + "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": 70, + "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": 54, + "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": 62, + "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": 60, + "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": 60, + "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_BatchRemoveCatalogAttributes_async", + "title": "CatalogService batchRemoveCatalogAttributes Sample", + "origin": "API_DEFINITION", + "description": " Removes all specified [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute]s from the [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig].", + "canonical": true, + "file": "catalog_service.batch_remove_catalog_attributes.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 62, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BatchRemoveCatalogAttributes", + "fullName": "google.cloud.retail.v2beta.CatalogService.BatchRemoveCatalogAttributes", + "async": true, + "parameters": [ + { + "name": "attributes_config", + "type": "TYPE_STRING" + }, + { + "name": "attribute_keys", + "type": "TYPE_STRING[]" + } + ], + "resultType": ".google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse", + "client": { + "shortName": "CatalogServiceClient", + "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" + }, + "method": { + "shortName": "BatchRemoveCatalogAttributes", + "fullName": "google.cloud.retail.v2beta.CatalogService.BatchRemoveCatalogAttributes", + "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": 68, + "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. Enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "completion_service.complete_query.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 124, + "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" + }, + { + "name": "entity", + "type": "TYPE_STRING" + } + ], + "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. 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": 68, + "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": 67, + "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": 54, + "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 update does not exist, a NOT_FOUND error is returned.", + "canonical": true, + "file": "control_service.update_control.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 61, + "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": 54, + "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 by their parent [Catalog][google.cloud.retail.v2beta.Catalog].", + "canonical": true, + "file": "control_service.list_controls.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 74, + "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_ModelService_CreateModel_async", + "title": "CatalogService createModel Sample", + "origin": "API_DEFINITION", + "description": " Creates a new model.", + "canonical": true, + "file": "model_service.create_model.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateModel", + "fullName": "google.cloud.retail.v2beta.ModelService.CreateModel", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "model", + "type": ".google.cloud.retail.v2beta.Model" + }, + { + "name": "dry_run", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ModelServiceClient", + "fullName": "google.cloud.retail.v2beta.ModelServiceClient" + }, + "method": { + "shortName": "CreateModel", + "fullName": "google.cloud.retail.v2beta.ModelService.CreateModel", + "service": { + "shortName": "ModelService", + "fullName": "google.cloud.retail.v2beta.ModelService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ModelService_GetModel_async", + "title": "CatalogService getModel Sample", + "origin": "API_DEFINITION", + "description": " Gets a model.", + "canonical": true, + "file": "model_service.get_model.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetModel", + "fullName": "google.cloud.retail.v2beta.ModelService.GetModel", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.Model", + "client": { + "shortName": "ModelServiceClient", + "fullName": "google.cloud.retail.v2beta.ModelServiceClient" + }, + "method": { + "shortName": "GetModel", + "fullName": "google.cloud.retail.v2beta.ModelService.GetModel", + "service": { + "shortName": "ModelService", + "fullName": "google.cloud.retail.v2beta.ModelService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ModelService_PauseModel_async", + "title": "CatalogService pauseModel Sample", + "origin": "API_DEFINITION", + "description": " Pauses the training of an existing model.", + "canonical": true, + "file": "model_service.pause_model.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "PauseModel", + "fullName": "google.cloud.retail.v2beta.ModelService.PauseModel", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.Model", + "client": { + "shortName": "ModelServiceClient", + "fullName": "google.cloud.retail.v2beta.ModelServiceClient" + }, + "method": { + "shortName": "PauseModel", + "fullName": "google.cloud.retail.v2beta.ModelService.PauseModel", + "service": { + "shortName": "ModelService", + "fullName": "google.cloud.retail.v2beta.ModelService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ModelService_ResumeModel_async", + "title": "CatalogService resumeModel Sample", + "origin": "API_DEFINITION", + "description": " Resumes the training of an existing model.", + "canonical": true, + "file": "model_service.resume_model.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ResumeModel", + "fullName": "google.cloud.retail.v2beta.ModelService.ResumeModel", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.retail.v2beta.Model", + "client": { + "shortName": "ModelServiceClient", + "fullName": "google.cloud.retail.v2beta.ModelServiceClient" + }, + "method": { + "shortName": "ResumeModel", + "fullName": "google.cloud.retail.v2beta.ModelService.ResumeModel", + "service": { + "shortName": "ModelService", + "fullName": "google.cloud.retail.v2beta.ModelService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ModelService_DeleteModel_async", + "title": "CatalogService deleteModel Sample", + "origin": "API_DEFINITION", + "description": " Deletes an existing model.", + "canonical": true, + "file": "model_service.delete_model.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 55, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteModel", + "fullName": "google.cloud.retail.v2beta.ModelService.DeleteModel", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "ModelServiceClient", + "fullName": "google.cloud.retail.v2beta.ModelServiceClient" + }, + "method": { + "shortName": "DeleteModel", + "fullName": "google.cloud.retail.v2beta.ModelService.DeleteModel", + "service": { + "shortName": "ModelService", + "fullName": "google.cloud.retail.v2beta.ModelService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ModelService_ListModels_async", + "title": "CatalogService listModels Sample", + "origin": "API_DEFINITION", + "description": " Lists all the models linked to this event store.", + "canonical": true, + "file": "model_service.list_models.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 67, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListModels", + "fullName": "google.cloud.retail.v2beta.ModelService.ListModels", + "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.ListModelsResponse", + "client": { + "shortName": "ModelServiceClient", + "fullName": "google.cloud.retail.v2beta.ModelServiceClient" + }, + "method": { + "shortName": "ListModels", + "fullName": "google.cloud.retail.v2beta.ModelService.ListModels", + "service": { + "shortName": "ModelService", + "fullName": "google.cloud.retail.v2beta.ModelService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ModelService_UpdateModel_async", + "title": "CatalogService updateModel Sample", + "origin": "API_DEFINITION", + "description": " Update of model metadata. Only fields that currently can be updated are: `filtering_option` and `periodic_tuning_state`. If other values are provided, this API method ignores them.", + "canonical": true, + "file": "model_service.update_model.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateModel", + "fullName": "google.cloud.retail.v2beta.ModelService.UpdateModel", + "async": true, + "parameters": [ + { + "name": "model", + "type": ".google.cloud.retail.v2beta.Model" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.retail.v2beta.Model", + "client": { + "shortName": "ModelServiceClient", + "fullName": "google.cloud.retail.v2beta.ModelServiceClient" + }, + "method": { + "shortName": "UpdateModel", + "fullName": "google.cloud.retail.v2beta.ModelService.UpdateModel", + "service": { + "shortName": "ModelService", + "fullName": "google.cloud.retail.v2beta.ModelService" + } + } + } + }, + { + "regionTag": "retail_v2beta_generated_ModelService_TuneModel_async", + "title": "CatalogService tuneModel Sample", + "origin": "API_DEFINITION", + "description": " Tunes an existing model.", + "canonical": true, + "file": "model_service.tune_model.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 56, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TuneModel", + "fullName": "google.cloud.retail.v2beta.ModelService.TuneModel", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "ModelServiceClient", + "fullName": "google.cloud.retail.v2beta.ModelServiceClient" + }, + "method": { + "shortName": "TuneModel", + "fullName": "google.cloud.retail.v2beta.ModelService.TuneModel", + "service": { + "shortName": "ModelService", + "fullName": "google.cloud.retail.v2beta.ModelService" + } + } + } + }, + { + "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": 179, + "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": 75, + "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": 60, + "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": 127, + "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": 79, + "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": 70, + "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. 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": 90, + "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 is 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 [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. When inventory is updated with [ProductService.CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] and [ProductService.UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct], the specified inventory field value(s) overwrite any existing value(s) while ignoring the last update time for this field. Furthermore, the last update times for the specified inventory fields are overwritten by the times of the [ProductService.CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] or [ProductService.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 is used. If no inventory fields are set in [SetInventoryRequest.set_mask][google.cloud.retail.v2beta.SetInventoryRequest.set_mask], then any existing inventory information is preserved. Pre-existing inventory information can only be updated with [ProductService.SetInventory][google.cloud.retail.v2beta.ProductService.SetInventory], [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.AddFulfillmentPlaces], and [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces]. The returned [Operation][google.longrunning.Operation]s is obsolete after one day, and the [GetOperation][google.longrunning.Operations.GetOperation] API returns `NOT_FOUND` afterwards. If conflicting updates are issued, the [Operation][google.longrunning.Operation]s associated with the stale updates are not marked as [done][google.longrunning.Operation.done] until they are obsolete.", + "canonical": true, + "file": "product_service.set_inventory.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 123, + "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": " It is recommended to use the [ProductService.AddLocalInventories][google.cloud.retail.v2beta.ProductService.AddLocalInventories] method instead of [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.AddFulfillmentPlaces]. [ProductService.AddLocalInventories][google.cloud.retail.v2beta.ProductService.AddLocalInventories] achieves the same results but provides more fine-grained control over ingesting local inventory data. 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 [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. The returned [Operation][google.longrunning.Operation]s will be obsolete after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] API will return NOT_FOUND afterwards. If conflicting updates are issued, the [Operation][google.longrunning.Operation]s associated with the stale updates will not be marked as [done][google.longrunning.Operation.done] until being obsolete.", + "canonical": true, + "file": "product_service.add_fulfillment_places.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 111, + "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": " It is recommended to use the [ProductService.RemoveLocalInventories][google.cloud.retail.v2beta.ProductService.RemoveLocalInventories] method instead of [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces]. [ProductService.RemoveLocalInventories][google.cloud.retail.v2beta.ProductService.RemoveLocalInventories] achieves the same results but provides more fine-grained control over ingesting local inventory data. 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 [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. The returned [Operation][google.longrunning.Operation]s will be obsolete after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] API will return NOT_FOUND afterwards. If conflicting updates are issued, the [Operation][google.longrunning.Operation]s associated with the stale updates will not be marked as [done][google.longrunning.Operation.done] until being obsolete.", + "canonical": true, + "file": "product_service.remove_fulfillment_places.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 107, + "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 [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. Local inventory information can only be modified using this method. [ProductService.CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] and [ProductService.UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct] has no effect on local inventories. The returned [Operation][google.longrunning.Operation]s will be obsolete after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] API will return NOT_FOUND afterwards. If conflicting updates are issued, the [Operation][google.longrunning.Operation]s associated with the stale updates will not be marked as [done][google.longrunning.Operation.done] until being obsolete.", + "canonical": true, + "file": "product_service.add_local_inventories.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 95, + "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 [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. Local inventory information can only be removed using this method. [ProductService.CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] and [ProductService.UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct] has no effect on local inventories. The returned [Operation][google.longrunning.Operation]s will be obsolete after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] API will return NOT_FOUND afterwards. If conflicting updates are issued, the [Operation][google.longrunning.Operation]s associated with the stale updates will not be marked as [done][google.longrunning.Operation.done] until being obsolete.", + "canonical": true, + "file": "product_service.remove_local_inventories.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 80, + "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. Enable Retail Search on Cloud Console before using this feature.", + "canonical": true, + "file": "search_service.search.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 304, + "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" + }, + { + "name": "labels", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "spell_correction_spec", + "type": ".google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec" + }, + { + "name": "entity", + "type": "TYPE_STRING" + } + ], + "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": 67, + "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": 54, + "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": 61, + "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": 54, + "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": 67, + "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": 60, + "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": 60, + "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": 66, + "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" + }, + { + "name": "write_async", + "type": "TYPE_BOOL" + } + ], + "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": 85, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CollectUserEvent", + "fullName": "google.cloud.retail.v2beta.UserEventService.CollectUserEvent", + "async": true, + "parameters": [ + { + "name": "prebuilt_rule", + "type": "TYPE_STRING" + }, + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "user_event", + "type": "TYPE_STRING" + }, + { + "name": "uri", + "type": "TYPE_STRING" + }, + { + "name": "ets", + "type": "TYPE_INT64" + }, + { + "name": "raw_json", + "type": "TYPE_STRING" + } + ], + "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": 86, + "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": 64, + "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 are not annotated with detailed product information for products that are missing from the catalog when the user event is ingested. These events are stored as unjoined events with limited usage on training and serving. You can use this method to start a join operation on specified events with the latest version of product catalog. You can also use this method 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": 62, + "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/google-cloud-retail/v2beta/samples/generated/v2beta/user_event_service.collect_user_event.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/user_event_service.collect_user_event.js new file mode 100644 index 00000000000..90657a3b92b --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/user_event_service.collect_user_event.js @@ -0,0 +1,93 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * The prebuilt rule name that can convert a specific type of raw_json. + * For example: "ga4_bq" rule for the GA4 user event schema. + */ + // const prebuiltRule = 'abc123' + /** + * 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 + /** + * An arbitrary serialized JSON string that contains necessary information + * that can comprise a user event. When this field is specified, the + * user_event field will be ignored. Note: line-delimited JSON is not + * supported, a single JSON only. + */ + // const rawJson = 'abc123' + + // 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/google-cloud-retail/v2beta/samples/generated/v2beta/user_event_service.import_user_events.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/user_event_service.import_user_events.js new file mode 100644 index 00000000000..6ace38eb656 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/user_event_service.import_user_events.js @@ -0,0 +1,72 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * 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/google-cloud-retail/v2beta/samples/generated/v2beta/user_event_service.purge_user_events.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/user_event_service.purge_user_events.js new file mode 100644 index 00000000000..82335eaee23 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/user_event_service.purge_user_events.js @@ -0,0 +1,94 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The resource name of the 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/google-cloud-retail/v2beta/samples/generated/v2beta/user_event_service.rejoin_user_events.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/user_event_service.rejoin_user_events.js new file mode 100644 index 00000000000..08e816c0a68 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/user_event_service.rejoin_user_events.js @@ -0,0 +1,70 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent 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/google-cloud-retail/v2beta/samples/generated/v2beta/user_event_service.write_user_event.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/user_event_service.write_user_event.js new file mode 100644 index 00000000000..2e2222f9d90 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/user_event_service.write_user_event.js @@ -0,0 +1,74 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated 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] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The parent catalog resource name, such as + * `projects/1234/locations/global/catalogs/default_catalog`. + */ + // const parent = 'abc123' + /** + * Required. User event to write. + */ + // const userEvent = {} + /** + * If set to true, the user event will be written asynchronously after + * validation, and the API will respond without waiting for the write. + * Therefore, silent failures can occur even if the API returns success. In + * case of silent failures, error messages can be found in Stackdriver logs. + */ + // const writeAsync = true + + // 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/google-cloud-retail/v2beta/src/index.ts b/owl-bot-staging/google-cloud-retail/v2beta/src/index.ts new file mode 100644 index 00000000000..87d258343ac --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/src/index.ts @@ -0,0 +1,41 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This 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 ModelServiceClient = v2beta.ModelServiceClient; +type ModelServiceClient = v2beta.ModelServiceClient; +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, ModelServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, ServingConfigServiceClient, UserEventServiceClient}; +export default {v2beta, CatalogServiceClient, CompletionServiceClient, ControlServiceClient, ModelServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, ServingConfigServiceClient, UserEventServiceClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/catalog_service_client.ts b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/catalog_service_client.ts new file mode 100644 index 00000000000..2bf80acd632 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/catalog_service_client.ts @@ -0,0 +1,2304 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/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}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + 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/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new CatalogServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof 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); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + 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}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + 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') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',additional_bindings: [{get: '/v2beta/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2beta/{name=projects/*/locations/*/operations/*}',},{get: '/v2beta/{name=projects/*/operations/*}',}], + },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2beta/{name=projects/*/locations/*/catalogs/*}/operations',additional_bindings: [{get: '/v2beta/{name=projects/*/locations/*}/operations',},{get: '/v2beta/{name=projects/*}/operations',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + + this.descriptors.longrunning = { + }; + + // 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 = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.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', 'batchRemoveCatalogAttributes', '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._opts.fallback + ); + + 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 {@link google.cloud.retail.v2beta.Catalog | 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' + ] = this._gaxModule.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 {@link google.protobuf.Empty | 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' + ] = this._gaxModule.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 {@link google.cloud.retail.v2beta.GetDefaultBranchResponse | 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' + ] = this._gaxModule.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 {@link google.cloud.retail.v2beta.CompletionConfig | 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' + ] = this._gaxModule.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 {@link google.cloud.retail.v2beta.CompletionConfig | 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' + ] = this._gaxModule.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 {@link google.cloud.retail.v2beta.AttributesConfig | 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' + ] = this._gaxModule.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 {@link google.cloud.retail.v2beta.AttributesConfig | 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' + ] = this._gaxModule.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 {@link google.cloud.retail.v2beta.AttributesConfig | 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' + ] = this._gaxModule.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 {@link google.cloud.retail.v2beta.AttributesConfig | 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'attributes_config': request.attributesConfig ?? '', + }); + this.initialize(); + return this.innerApiCalls.removeCatalogAttribute(request, options, callback); + } +/** + * Removes all specified + * {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute}s from the + * {@link google.cloud.retail.v2beta.AttributesConfig|AttributesConfig}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.attributesConfig + * Required. The attributes config resource shared by all catalog attributes + * being deleted. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` + * @param {string[]} request.attributeKeys + * Required. The attribute name keys of the + * {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute}s to delete. + * A maximum of 1000 catalog attributes can be deleted in a batch. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse | BatchRemoveCatalogAttributesResponse}. + * Please see 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.batch_remove_catalog_attributes.js + * region_tag:retail_v2beta_generated_CatalogService_BatchRemoveCatalogAttributes_async + */ + batchRemoveCatalogAttributes( + request?: protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesResponse, + protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesRequest|undefined, {}|undefined + ]>; + batchRemoveCatalogAttributes( + request: protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesResponse, + protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesRequest|null|undefined, + {}|null|undefined>): void; + batchRemoveCatalogAttributes( + request: protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesResponse, + protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesRequest|null|undefined, + {}|null|undefined>): void; + batchRemoveCatalogAttributes( + request?: protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesResponse, + protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesResponse, + protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesResponse, + protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'attributes_config': request.attributesConfig ?? '', + }); + this.initialize(); + return this.innerApiCalls.batchRemoveCatalogAttributes(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 {@link google.cloud.retail.v2beta.AttributesConfig | 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' + ] = this._gaxModule.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 {@link google.cloud.retail.v2beta.Catalog | 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' + ] = this._gaxModule.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 {@link google.cloud.retail.v2beta.Catalog | 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' + ] = this._gaxModule.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 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 + * {@link google.cloud.retail.v2beta.Catalog | 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' + ] = this._gaxModule.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 {}, + callSettings + ) as AsyncIterable; + } +/** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + +/** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + +/** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified 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 model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project:string,location:string,catalog:string,model:string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * 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(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/catalog_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/catalog_service_client_config.json new file mode 100644 index 00000000000..3554c7046eb --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/catalog_service_client_config.json @@ -0,0 +1,95 @@ +{ + "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" + }, + "BatchRemoveCatalogAttributes": { + "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/google-cloud-retail/v2beta/src/v2beta/catalog_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/catalog_service_proto_list.json new file mode 100644 index 00000000000..ce2a33ebd29 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/catalog_service_proto_list.json @@ -0,0 +1,22 @@ +[ + "../../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/model.proto", + "../../protos/google/cloud/retail/v2beta/model_service.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/google-cloud-retail/v2beta/src/v2beta/completion_service_client.ts b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/completion_service_client.ts new file mode 100644 index 00000000000..12516895121 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/completion_service_client.ts @@ -0,0 +1,1294 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, LocationsClient, LocationProtos} 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'; +const version = require('../../../package.json').version; + +/** + * Autocomplete service for retail. + * + * This feature is only available for users who have Retail Search enabled. + * 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}; + locationsClient: LocationsClient; + 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/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new CompletionServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof 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); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + 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}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + 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. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',additional_bindings: [{get: '/v2beta/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2beta/{name=projects/*/locations/*/operations/*}',},{get: '/v2beta/{name=projects/*/operations/*}',}], + },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2beta/{name=projects/*/locations/*/catalogs/*}/operations',additional_bindings: [{get: '/v2beta/{name=projects/*/locations/*}/operations',},{get: '/v2beta/{name=projects/*}/operations',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).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 = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.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._opts.fallback + ); + + 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. + * 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 + * Note that this field applies for `user-data` dataset only. For requests + * with `cloud-retail` dataset, setting this field has no effect. + * + * 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. We recommend that you + * leave this field empty. + * + * It can 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 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 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 {string} request.entity + * The entity for customers that may run multiple different entities, domains, + * sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, + * `google.com`, `youtube.com`, etc. + * If this is set, it should be exactly matched with + * {@link google.cloud.retail.v2beta.UserEvent.entity|UserEvent.entity} to get + * per-entity autocomplete results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.retail.v2beta.CompleteQueryResponse | 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' + ] = this._gaxModule.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. + * 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 is sent to + * specified Pub/Sub topic. The message data is 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' + ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.importCompletionData, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + +/** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + +/** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified 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 model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project:string,location:string,catalog:string,model:string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * 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.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/completion_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/completion_service_client_config.json new file mode 100644 index 00000000000..1865fe66ef1 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2beta/src/v2beta/completion_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/completion_service_proto_list.json new file mode 100644 index 00000000000..ce2a33ebd29 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/completion_service_proto_list.json @@ -0,0 +1,22 @@ +[ + "../../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/model.proto", + "../../protos/google/cloud/retail/v2beta/model_service.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/google-cloud-retail/v2beta/src/v2beta/control_service_client.ts b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/control_service_client.ts new file mode 100644 index 00000000000..96b60e56165 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/control_service_client.ts @@ -0,0 +1,1556 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/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}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + 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/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new ControlServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof 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); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + 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}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + 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') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',additional_bindings: [{get: '/v2beta/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2beta/{name=projects/*/locations/*/operations/*}',},{get: '/v2beta/{name=projects/*/operations/*}',}], + },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2beta/{name=projects/*/locations/*/catalogs/*}/operations',additional_bindings: [{get: '/v2beta/{name=projects/*/locations/*}/operations',},{get: '/v2beta/{name=projects/*}/operations',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + + this.descriptors.longrunning = { + }; + + // 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 = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.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._opts.fallback + ); + + 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 {@link google.cloud.retail.v2beta.Control | 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' + ] = this._gaxModule.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 {@link google.protobuf.Empty | 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' + ] = this._gaxModule.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 update 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 {@link google.cloud.retail.v2beta.Control | 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' + ] = this._gaxModule.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 get. 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 {@link google.cloud.retail.v2beta.Control | 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getControl(request, options, callback); + } + + /** + * Lists all Controls by their parent + * {@link google.cloud.retail.v2beta.Catalog|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 {@link google.cloud.retail.v2beta.Control | 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' + ] = this._gaxModule.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 {@link google.cloud.retail.v2beta.Control | 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' + ] = this._gaxModule.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 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 + * {@link google.cloud.retail.v2beta.Control | 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' + ] = this._gaxModule.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 {}, + callSettings + ) as AsyncIterable; + } +/** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + +/** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + +/** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified 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 model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project:string,location:string,catalog:string,model:string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * 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(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/control_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/control_service_client_config.json new file mode 100644 index 00000000000..b7572aeb833 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2beta/src/v2beta/control_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/control_service_proto_list.json new file mode 100644 index 00000000000..ce2a33ebd29 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/control_service_proto_list.json @@ -0,0 +1,22 @@ +[ + "../../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/model.proto", + "../../protos/google/cloud/retail/v2beta/model_service.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/google-cloud-retail/v2beta/src/v2beta/gapic_metadata.json b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/gapic_metadata.json new file mode 100644 index 00000000000..9fa0d1c4170 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/gapic_metadata.json @@ -0,0 +1,679 @@ +{ + "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" + ] + }, + "BatchRemoveCatalogAttributes": { + "methods": [ + "batchRemoveCatalogAttributes" + ] + }, + "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" + ] + }, + "BatchRemoveCatalogAttributes": { + "methods": [ + "batchRemoveCatalogAttributes" + ] + }, + "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" + ] + } + } + } + } + }, + "ModelService": { + "clients": { + "grpc": { + "libraryClient": "ModelServiceClient", + "rpcs": { + "GetModel": { + "methods": [ + "getModel" + ] + }, + "PauseModel": { + "methods": [ + "pauseModel" + ] + }, + "ResumeModel": { + "methods": [ + "resumeModel" + ] + }, + "DeleteModel": { + "methods": [ + "deleteModel" + ] + }, + "UpdateModel": { + "methods": [ + "updateModel" + ] + }, + "CreateModel": { + "methods": [ + "createModel" + ] + }, + "TuneModel": { + "methods": [ + "tuneModel" + ] + }, + "ListModels": { + "methods": [ + "listModels", + "listModelsStream", + "listModelsAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "ModelServiceClient", + "rpcs": { + "GetModel": { + "methods": [ + "getModel" + ] + }, + "PauseModel": { + "methods": [ + "pauseModel" + ] + }, + "ResumeModel": { + "methods": [ + "resumeModel" + ] + }, + "DeleteModel": { + "methods": [ + "deleteModel" + ] + }, + "UpdateModel": { + "methods": [ + "updateModel" + ] + }, + "CreateModel": { + "methods": [ + "createModel" + ] + }, + "TuneModel": { + "methods": [ + "tuneModel" + ] + }, + "ListModels": { + "methods": [ + "listModels", + "listModelsStream", + "listModelsAsync" + ] + } + } + } + } + }, + "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/google-cloud-retail/v2beta/src/v2beta/index.ts b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/index.ts new file mode 100644 index 00000000000..24ad5baba84 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/index.ts @@ -0,0 +1,27 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {ModelServiceClient} from './model_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/google-cloud-retail/v2beta/src/v2beta/model_service_client.ts b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/model_service_client.ts new file mode 100644 index 00000000000..22896921fbe --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/model_service_client.ts @@ -0,0 +1,1812 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v2beta/model_service_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './model_service_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Service for performing CRUD operations on models. + * Recommendation models contain all the metadata necessary to generate a set of + * models for the `Predict()` API. A model is queried + * indirectly via a ServingConfig, which associates a model with a + * given Placement (e.g. Frequently Bought Together on Home Page). + * + * This service allows you to do the following: + * + * * Initiate training of a model. + * * Pause training of an existing model. + * * List all the available models along with their metadata. + * * Control their tuning schedule. + * @class + * @memberof v2beta + */ +export class ModelServiceClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + modelServiceStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of ModelServiceClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new ModelServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof ModelServiceClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + 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}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + 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 = { + listModels: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'models') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',additional_bindings: [{get: '/v2beta/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2beta/{name=projects/*/locations/*/operations/*}',},{get: '/v2beta/{name=projects/*/operations/*}',}], + },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2beta/{name=projects/*/locations/*/catalogs/*}/operations',additional_bindings: [{get: '/v2beta/{name=projects/*/locations/*}/operations',},{get: '/v2beta/{name=projects/*}/operations',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + const createModelResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.Model') as gax.protobuf.Type; + const createModelMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.CreateModelMetadata') as gax.protobuf.Type; + const tuneModelResponse = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.TuneModelResponse') as gax.protobuf.Type; + const tuneModelMetadata = protoFilesRoot.lookup( + '.google.cloud.retail.v2beta.TuneModelMetadata') as gax.protobuf.Type; + + this.descriptors.longrunning = { + createModel: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createModelResponse.decode.bind(createModelResponse), + createModelMetadata.decode.bind(createModelMetadata)), + tuneModel: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + tuneModelResponse.decode.bind(tuneModelResponse), + tuneModelMetadata.decode.bind(tuneModelMetadata)) + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.retail.v2beta.ModelService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.modelServiceStub) { + return this.modelServiceStub; + } + + // Put together the "service stub" for + // google.cloud.retail.v2beta.ModelService. + this.modelServiceStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2beta.ModelService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.retail.v2beta.ModelService, + 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 modelServiceStubMethods = + ['createModel', 'getModel', 'pauseModel', 'resumeModel', 'deleteModel', 'listModels', 'updateModel', 'tuneModel']; + for (const methodName of modelServiceStubMethods) { + const callPromise = this.modelServiceStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + this.descriptors.longrunning[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.modelServiceStub; + } + + /** + * 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 -- + // ------------------- +/** + * Gets a model. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the + * {@link google.cloud.retail.v2beta.Model|Model} to get. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog}/models/{model_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 {@link google.cloud.retail.v2beta.Model | Model}. + * Please see 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/model_service.get_model.js + * region_tag:retail_v2beta_generated_ModelService_GetModel_async + */ + getModel( + request?: protos.google.cloud.retail.v2beta.IGetModelRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.IGetModelRequest|undefined, {}|undefined + ]>; + getModel( + request: protos.google.cloud.retail.v2beta.IGetModelRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.IGetModelRequest|null|undefined, + {}|null|undefined>): void; + getModel( + request: protos.google.cloud.retail.v2beta.IGetModelRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.IGetModelRequest|null|undefined, + {}|null|undefined>): void; + getModel( + request?: protos.google.cloud.retail.v2beta.IGetModelRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.IGetModelRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.IGetModelRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.IGetModelRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.getModel(request, options, callback); + } +/** + * Pauses the training of an existing model. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the model to pause. + * Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_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 {@link google.cloud.retail.v2beta.Model | Model}. + * Please see 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/model_service.pause_model.js + * region_tag:retail_v2beta_generated_ModelService_PauseModel_async + */ + pauseModel( + request?: protos.google.cloud.retail.v2beta.IPauseModelRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.IPauseModelRequest|undefined, {}|undefined + ]>; + pauseModel( + request: protos.google.cloud.retail.v2beta.IPauseModelRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.IPauseModelRequest|null|undefined, + {}|null|undefined>): void; + pauseModel( + request: protos.google.cloud.retail.v2beta.IPauseModelRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.IPauseModelRequest|null|undefined, + {}|null|undefined>): void; + pauseModel( + request?: protos.google.cloud.retail.v2beta.IPauseModelRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.IPauseModelRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.IPauseModelRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.IPauseModelRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.pauseModel(request, options, callback); + } +/** + * Resumes the training of an existing model. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the model to resume. + * Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_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 {@link google.cloud.retail.v2beta.Model | Model}. + * Please see 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/model_service.resume_model.js + * region_tag:retail_v2beta_generated_ModelService_ResumeModel_async + */ + resumeModel( + request?: protos.google.cloud.retail.v2beta.IResumeModelRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.IResumeModelRequest|undefined, {}|undefined + ]>; + resumeModel( + request: protos.google.cloud.retail.v2beta.IResumeModelRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.IResumeModelRequest|null|undefined, + {}|null|undefined>): void; + resumeModel( + request: protos.google.cloud.retail.v2beta.IResumeModelRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.IResumeModelRequest|null|undefined, + {}|null|undefined>): void; + resumeModel( + request?: protos.google.cloud.retail.v2beta.IResumeModelRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.IResumeModelRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.IResumeModelRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.IResumeModelRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.resumeModel(request, options, callback); + } +/** + * Deletes an existing model. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the + * {@link google.cloud.retail.v2beta.Model|Model} to delete. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_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 {@link google.protobuf.Empty | 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/model_service.delete_model.js + * region_tag:retail_v2beta_generated_ModelService_DeleteModel_async + */ + deleteModel( + request?: protos.google.cloud.retail.v2beta.IDeleteModelRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteModelRequest|undefined, {}|undefined + ]>; + deleteModel( + request: protos.google.cloud.retail.v2beta.IDeleteModelRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteModelRequest|null|undefined, + {}|null|undefined>): void; + deleteModel( + request: protos.google.cloud.retail.v2beta.IDeleteModelRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteModelRequest|null|undefined, + {}|null|undefined>): void; + deleteModel( + request?: protos.google.cloud.retail.v2beta.IDeleteModelRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteModelRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteModelRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.retail.v2beta.IDeleteModelRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.deleteModel(request, options, callback); + } +/** + * Update of model metadata. Only fields that + * currently can be updated are: `filtering_option` and + * `periodic_tuning_state`. + * If other values are provided, this API method ignores them. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.retail.v2beta.Model} request.model + * Required. The body of the updated + * {@link google.cloud.retail.v2beta.Model|Model}. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Indicates which fields in the provided 'model' to + * update. If not set, by default updates all fields. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.retail.v2beta.Model | Model}. + * Please see 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/model_service.update_model.js + * region_tag:retail_v2beta_generated_ModelService_UpdateModel_async + */ + updateModel( + request?: protos.google.cloud.retail.v2beta.IUpdateModelRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.IUpdateModelRequest|undefined, {}|undefined + ]>; + updateModel( + request: protos.google.cloud.retail.v2beta.IUpdateModelRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.IUpdateModelRequest|null|undefined, + {}|null|undefined>): void; + updateModel( + request: protos.google.cloud.retail.v2beta.IUpdateModelRequest, + callback: Callback< + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.IUpdateModelRequest|null|undefined, + {}|null|undefined>): void; + updateModel( + request?: protos.google.cloud.retail.v2beta.IUpdateModelRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.IUpdateModelRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.IUpdateModelRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.retail.v2beta.IModel, + protos.google.cloud.retail.v2beta.IUpdateModelRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'model.name': request.model!.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.updateModel(request, options, callback); + } + +/** + * Creates a new model. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource under which to create the model. Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` + * @param {google.cloud.retail.v2beta.Model} request.model + * Required. The payload of the {@link google.cloud.retail.v2beta.Model|Model} to + * create. + * @param {boolean} [request.dryRun] + * Optional. Whether to run a dry run to validate the request (without + * actually creating the model). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [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/model_service.create_model.js + * region_tag:retail_v2beta_generated_ModelService_CreateModel_async + */ + createModel( + request?: protos.google.cloud.retail.v2beta.ICreateModelRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + createModel( + request: protos.google.cloud.retail.v2beta.ICreateModelRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createModel( + request: protos.google.cloud.retail.v2beta.ICreateModelRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + createModel( + request?: protos.google.cloud.retail.v2beta.ICreateModelRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createModel(request, options, callback); + } +/** + * Check the status of the long running operation returned by `createModel()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [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/model_service.create_model.js + * region_tag:retail_v2beta_generated_ModelService_CreateModel_async + */ + async checkCreateModelProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createModel, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Tunes an existing model. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the model to tune. + * Format: + * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [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/model_service.tune_model.js + * region_tag:retail_v2beta_generated_ModelService_TuneModel_async + */ + tuneModel( + request?: protos.google.cloud.retail.v2beta.ITuneModelRequest, + options?: CallOptions): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>; + tuneModel( + request: protos.google.cloud.retail.v2beta.ITuneModelRequest, + options: CallOptions, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + tuneModel( + request: protos.google.cloud.retail.v2beta.ITuneModelRequest, + callback: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; + tuneModel( + request?: protos.google.cloud.retail.v2beta.ITuneModelRequest, + optionsOrCallback?: CallOptions|Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, + callback?: Callback< + LROperation, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): + Promise<[ + LROperation, + protos.google.longrunning.IOperation|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'name': request.name ?? '', + }); + this.initialize(); + return this.innerApiCalls.tuneModel(request, options, callback); + } +/** + * Check the status of the long running operation returned by `tuneModel()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [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/model_service.tune_model.js + * region_tag:retail_v2beta_generated_ModelService_TuneModel_async + */ + async checkTuneModelProgress(name: string): Promise>{ + const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.tuneModel, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } + /** + * Lists all the models linked to this event store. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent for which to list models. + * 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 `ListModels` + * 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 {@link google.cloud.retail.v2beta.Model | Model}. + * 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 `listModelsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listModels( + request?: protos.google.cloud.retail.v2beta.IListModelsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.retail.v2beta.IModel[], + protos.google.cloud.retail.v2beta.IListModelsRequest|null, + protos.google.cloud.retail.v2beta.IListModelsResponse + ]>; + listModels( + request: protos.google.cloud.retail.v2beta.IListModelsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.retail.v2beta.IListModelsRequest, + protos.google.cloud.retail.v2beta.IListModelsResponse|null|undefined, + protos.google.cloud.retail.v2beta.IModel>): void; + listModels( + request: protos.google.cloud.retail.v2beta.IListModelsRequest, + callback: PaginationCallback< + protos.google.cloud.retail.v2beta.IListModelsRequest, + protos.google.cloud.retail.v2beta.IListModelsResponse|null|undefined, + protos.google.cloud.retail.v2beta.IModel>): void; + listModels( + request?: protos.google.cloud.retail.v2beta.IListModelsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.retail.v2beta.IListModelsRequest, + protos.google.cloud.retail.v2beta.IListModelsResponse|null|undefined, + protos.google.cloud.retail.v2beta.IModel>, + callback?: PaginationCallback< + protos.google.cloud.retail.v2beta.IListModelsRequest, + protos.google.cloud.retail.v2beta.IListModelsResponse|null|undefined, + protos.google.cloud.retail.v2beta.IModel>): + Promise<[ + protos.google.cloud.retail.v2beta.IModel[], + protos.google.cloud.retail.v2beta.IListModelsRequest|null, + protos.google.cloud.retail.v2beta.IListModelsResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listModels(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 for which to list models. + * 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 `ListModels` + * 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 {@link google.cloud.retail.v2beta.Model | Model} 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 `listModelsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listModelsStream( + request?: protos.google.cloud.retail.v2beta.IListModelsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listModels']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listModels.createStream( + this.innerApiCalls.listModels as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listModels`, 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 for which to list models. + * 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 `ListModels` + * 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 + * {@link google.cloud.retail.v2beta.Model | Model}. 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/model_service.list_models.js + * region_tag:retail_v2beta_generated_ModelService_ListModels_async + */ + listModelsAsync( + request?: protos.google.cloud.retail.v2beta.IListModelsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listModels']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listModels.asyncIterate( + this.innerApiCalls['listModels'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } +/** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + +/** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + +/** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified 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 model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project:string,location:string,catalog:string,model:string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * 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.modelServiceStub && !this._terminated) { + return this.modelServiceStub.then(stub => { + this._terminated = true; + stub.close(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/model_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/model_service_client_config.json new file mode 100644 index 00000000000..49578702c95 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/model_service_client_config.json @@ -0,0 +1,58 @@ +{ + "interfaces": { + "google.cloud.retail.v2beta.ModelService": { + "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": { + "CreateModel": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetModel": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "PauseModel": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ResumeModel": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteModel": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListModels": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateModel": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TuneModel": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/model_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/model_service_proto_list.json new file mode 100644 index 00000000000..ce2a33ebd29 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/model_service_proto_list.json @@ -0,0 +1,22 @@ +[ + "../../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/model.proto", + "../../protos/google/cloud/retail/v2beta/model_service.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/google-cloud-retail/v2beta/src/v2beta/prediction_service_client.ts b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/prediction_service_client.ts new file mode 100644 index 00000000000..1a8829046d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/prediction_service_client.ts @@ -0,0 +1,1226 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LocationsClient, LocationProtos} 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}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + 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/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new PredictionServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof 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); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + 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}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + 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. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',additional_bindings: [{get: '/v2beta/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2beta/{name=projects/*/locations/*/operations/*}',},{get: '/v2beta/{name=projects/*/operations/*}',}], + },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2beta/{name=projects/*/locations/*/catalogs/*}/operations',additional_bindings: [{get: '/v2beta/{name=projects/*/locations/*}/operations',},{get: '/v2beta/{name=projects/*}/operations',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + + this.descriptors.longrunning = { + }; + + // 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 = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.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._opts.fallback + ); + + 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: + * `{placement=projects/* /locations/global/catalogs/default_catalog/servingConfigs/*}` + * or + * `{placement=projects/* /locations/global/catalogs/default_catalog/placements/*}`. + * We recommend using the `servingConfigs` resource. `placements` is a legacy + * resource. + * The ID of the Recommendations AI serving config or placement. + * Before you can request predictions from your model, you must create at + * least one serving config or placement for it. For more information, see + * [Manage serving configs] + * (https://cloud.google.com/retail/docs/manage-configs). + * + * The full list of available serving configs can be seen at + * https://console.cloud.google.com/ai/retail/catalogs/default_catalog/configs + * @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. + * + * Don't set + * {@link google.cloud.retail.v2beta.UserEvent.visitor_id|UserEvent.visitor_id} or + * {@link google.cloud.retail.v2beta.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.v2beta.UserEvent.visitor_id|UserEvent.visitor_id} to + * a random unique ID and leave + * {@link google.cloud.retail.v2beta.UserInfo.user_id|UserInfo.user_id} unset. + * @param {number} request.pageSize + * Maximum number of results to return. 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 + * This field is not used; leave it unset. + * @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 *no* + * results. If instead you want empty result sets to return generic + * (unfiltered) popular products, set `strictFiltering` to False in + * `PredictRequest.params`. Note that the API will never return items with + * storageStatus of "EXPIRED" or "DELETED" regardless of filter choices. + * + * If `filterSyntaxV2` is set to true under the `params` field, then + * attribute-based expressions are expected instead of the above described + * tag-based syntax. Examples: + * + * * (colors: ANY("Red", "Blue")) AND NOT (categories: ANY("Phones")) + * * (availability: ANY("IN_STOCK")) AND + * (colors: ANY("Red") OR categories: ANY("Phones")) + * + * For more information, see + * [Filter recommendations](https://cloud.google.com/retail/docs/filter-recs). + * @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 a 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. + * * `filterSyntaxV2`: Boolean. False by default. If set to true, the `filter` + * field is interpreteted according to the new, attribute-based syntax. + * @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 {@link google.cloud.retail.v2beta.PredictResponse | 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'placement': request.placement ?? '', + }); + this.initialize(); + return this.innerApiCalls.predict(request, options, callback); + } + +/** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + +/** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + +/** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified 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 model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project:string,location:string,catalog:string,model:string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * 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(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/prediction_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/prediction_service_client_config.json new file mode 100644 index 00000000000..ab64c45e11f --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2beta/src/v2beta/prediction_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/prediction_service_proto_list.json new file mode 100644 index 00000000000..ce2a33ebd29 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/prediction_service_proto_list.json @@ -0,0 +1,22 @@ +[ + "../../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/model.proto", + "../../protos/google/cloud/retail/v2beta/model_service.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/google-cloud-retail/v2beta/src/v2beta/product_service_client.ts b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/product_service_client.ts new file mode 100644 index 00000000000..e500acd18bb --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/product_service_client.ts @@ -0,0 +1,2865 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/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'; +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}; + locationsClient: LocationsClient; + 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/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new ProductServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof 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); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + 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}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + 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. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',additional_bindings: [{get: '/v2beta/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2beta/{name=projects/*/locations/*/operations/*}',},{get: '/v2beta/{name=projects/*/operations/*}',}], + },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2beta/{name=projects/*/locations/*/catalogs/*}/operations',additional_bindings: [{get: '/v2beta/{name=projects/*/locations/*}/operations',},{get: '/v2beta/{name=projects/*}/operations',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).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 = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.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._opts.fallback + ); + + 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 {@link google.cloud.retail.v2beta.Product | 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' + ] = this._gaxModule.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 {@link google.cloud.retail.v2beta.Product | 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' + ] = this._gaxModule.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. + * + * 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.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 {@link google.cloud.retail.v2beta.Product | 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' + ] = this._gaxModule.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 {@link google.protobuf.Empty | 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' + ] = this._gaxModule.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. + * 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, all fields are updated. + * @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 + * Full Pub/Sub topic name for receiving notification. If this field is set, + * when the import is finished, a notification is sent to + * specified Pub/Sub topic. The message data is 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.v2beta.ImportProductsRequest.parent|ImportProductsRequest.parent}. + * Make sure that `service-@gcp-sa-retail.iam.gserviceaccount.com` has the + * `pubsub.topics.publish` IAM permission on the 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/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' + ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.importProducts, this._gaxModule.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 is 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|ProductService.GetProduct} + * or + * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts}. + * + * When inventory is updated with + * {@link google.cloud.retail.v2beta.ProductService.CreateProduct|ProductService.CreateProduct} + * and + * {@link google.cloud.retail.v2beta.ProductService.UpdateProduct|ProductService.UpdateProduct}, + * the specified inventory field value(s) overwrite any existing value(s) + * while ignoring the last update time for this field. Furthermore, the last + * update times for the specified inventory fields are overwritten by the + * times of the + * {@link google.cloud.retail.v2beta.ProductService.CreateProduct|ProductService.CreateProduct} + * or + * {@link google.cloud.retail.v2beta.ProductService.UpdateProduct|ProductService.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 is used. + * + * If no inventory fields are set in + * {@link google.cloud.retail.v2beta.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask}, + * then any existing inventory information is preserved. + * + * Pre-existing inventory information can only be updated with + * {@link google.cloud.retail.v2beta.ProductService.SetInventory|ProductService.SetInventory}, + * {@link google.cloud.retail.v2beta.ProductService.AddFulfillmentPlaces|ProductService.AddFulfillmentPlaces}, + * and + * {@link google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces|ProductService.RemoveFulfillmentPlaces}. + * + * The returned {@link google.longrunning.Operation|Operation}s is obsolete after + * one day, and the {@link google.longrunning.Operations.GetOperation|GetOperation} + * API returns `NOT_FOUND` afterwards. + * + * If conflicting updates are issued, the + * {@link google.longrunning.Operation|Operation}s associated with the stale + * updates are not marked as {@link google.longrunning.Operation.done|done} until + * they are obsolete. + * + * @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 google.cloud.retail.v2beta.Product.name|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 google.cloud.retail.v2beta.Product.fulfillment_info|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 google.cloud.retail.v2beta.Product.fulfillment_info|SetInventoryRequest.inventory.fulfillment_info} + * * Checks that only the desired fulfillment info types have empty + * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|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 google.cloud.retail.v2beta.ProductService.UpdateProduct|ProductService.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' + ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.setInventory, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * It is recommended to use the + * {@link google.cloud.retail.v2beta.ProductService.AddLocalInventories|ProductService.AddLocalInventories} + * method instead of + * {@link google.cloud.retail.v2beta.ProductService.AddFulfillmentPlaces|ProductService.AddFulfillmentPlaces}. + * {@link google.cloud.retail.v2beta.ProductService.AddLocalInventories|ProductService.AddLocalInventories} + * achieves the same results but provides more fine-grained control over + * ingesting local inventory data. + * + * 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|ProductService.GetProduct} + * or + * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts}. + * + * The returned {@link google.longrunning.Operation|Operation}s will be obsolete + * after 1 day, and {@link google.longrunning.Operations.GetOperation|GetOperation} + * API will return NOT_FOUND afterwards. + * + * If conflicting updates are issued, the + * {@link google.longrunning.Operation|Operation}s associated with the stale + * updates will not be marked as {@link google.longrunning.Operation.done|done} + * until being obsolete. + * + * @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 google.cloud.retail.v2beta.FulfillmentInfo.type|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' + ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.addFulfillmentPlaces, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * It is recommended to use the + * {@link google.cloud.retail.v2beta.ProductService.RemoveLocalInventories|ProductService.RemoveLocalInventories} + * method instead of + * {@link google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces|ProductService.RemoveFulfillmentPlaces}. + * {@link google.cloud.retail.v2beta.ProductService.RemoveLocalInventories|ProductService.RemoveLocalInventories} + * achieves the same results but provides more fine-grained control over + * ingesting local inventory data. + * + * 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|ProductService.GetProduct} + * or + * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts}. + * + * The returned {@link google.longrunning.Operation|Operation}s will be obsolete + * after 1 day, and {@link google.longrunning.Operations.GetOperation|GetOperation} + * API will return NOT_FOUND afterwards. + * + * If conflicting updates are issued, the + * {@link google.longrunning.Operation|Operation}s associated with the stale + * updates will not be marked as {@link google.longrunning.Operation.done|done} + * until being obsolete. + * + * @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 google.cloud.retail.v2beta.FulfillmentInfo.type|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' + ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.removeFulfillmentPlaces, this._gaxModule.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|ProductService.GetProduct} + * or + * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts}. + * + * Local inventory information can only be modified using this method. + * {@link google.cloud.retail.v2beta.ProductService.CreateProduct|ProductService.CreateProduct} + * and + * {@link google.cloud.retail.v2beta.ProductService.UpdateProduct|ProductService.UpdateProduct} + * has no effect on local inventories. + * + * The returned {@link google.longrunning.Operation|Operation}s will be obsolete + * after 1 day, and {@link google.longrunning.Operations.GetOperation|GetOperation} + * API will return NOT_FOUND afterwards. + * + * If conflicting updates are issued, the + * {@link google.longrunning.Operation|Operation}s associated with the stale + * updates will not be marked as {@link google.longrunning.Operation.done|done} + * until being obsolete. + * + * @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' + ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.addLocalInventories, this._gaxModule.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|ProductService.GetProduct} + * or + * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts}. + * + * Local inventory information can only be removed using this method. + * {@link google.cloud.retail.v2beta.ProductService.CreateProduct|ProductService.CreateProduct} + * and + * {@link google.cloud.retail.v2beta.ProductService.UpdateProduct|ProductService.UpdateProduct} + * has no effect on local inventories. + * + * The returned {@link google.longrunning.Operation|Operation}s will be obsolete + * after 1 day, and {@link google.longrunning.Operations.GetOperation|GetOperation} + * API will return NOT_FOUND afterwards. + * + * If conflicting updates are issued, the + * {@link google.longrunning.Operation|Operation}s associated with the stale + * updates will not be marked as {@link google.longrunning.Operation.done|done} + * until being obsolete. + * + * @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' + ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.removeLocalInventories, this._gaxModule.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 {@link google.cloud.retail.v2beta.Product | 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.listProducts(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The 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 {@link google.cloud.retail.v2beta.Product | 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listProducts']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProducts.createStream( + this.innerApiCalls.listProducts as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listProducts`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The 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 + * {@link google.cloud.retail.v2beta.Product | 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' + ] = this._gaxModule.routingHeader.fromParams({ + 'parent': request.parent ?? '', + }); + const defaultCallSettings = this._defaults['listProducts']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listProducts.asyncIterate( + this.innerApiCalls['listProducts'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } +/** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + +/** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + +/** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified 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 model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project:string,location:string,catalog:string,model:string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * 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.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/product_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/product_service_client_config.json new file mode 100644 index 00000000000..459b579d7a8 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2beta/src/v2beta/product_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/product_service_proto_list.json new file mode 100644 index 00000000000..ce2a33ebd29 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/product_service_proto_list.json @@ -0,0 +1,22 @@ +[ + "../../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/model.proto", + "../../protos/google/cloud/retail/v2beta/model_service.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/google-cloud-retail/v2beta/src/v2beta/search_service_client.ts b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/search_service_client.ts new file mode 100644 index 00000000000..4fbb71261e3 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/search_service_client.ts @@ -0,0 +1,2043 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/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. + * 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}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + 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/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new SearchServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof 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); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + 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}' + ), + experimentPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/experiments/{experiment}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + 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') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',additional_bindings: [{get: '/v2beta/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2beta/{name=projects/*/locations/*/operations/*}',},{get: '/v2beta/{name=projects/*/operations/*}',}], + },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2beta/{name=projects/*/locations/*/catalogs/*}/operations',additional_bindings: [{get: '/v2beta/{name=projects/*/locations/*}/operations',},{get: '/v2beta/{name=projects/*}/operations',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + + this.descriptors.longrunning = { + }; + + // 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 = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.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._opts.fallback + ); + + 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. + * 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 Retail Search serving config, such as + * `projects/* /locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` + * or the name of the legacy placement resource, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. + * This field is used to identify the serving config 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.v2beta.SearchRequest.filter|filter} and + * {@link google.cloud.retail.v2beta.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.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 200 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 + * {@link google.cloud.retail.v2beta.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.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 google.cloud.retail.v2beta.LocalInventory.attributes|Product.local_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. Must be set 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, 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. + * + * Notice that if both + * {@link google.cloud.retail.v2beta.ServingConfig.personalization_spec|ServingConfig.personalization_spec} + * and + * {@link google.cloud.retail.v2beta.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * are set. + * {@link google.cloud.retail.v2beta.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * will override + * {@link google.cloud.retail.v2beta.ServingConfig.personalization_spec|ServingConfig.personalization_spec}. + * @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.v2beta.SearchRequest.SpellCorrectionSpec} request.spellCorrectionSpec + * The spell correction specification that specifies the mode under + * which spell correction will take effect. + * @param {string} request.entity + * The entity for customers that may run multiple different entities, domains, + * sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, + * `google.com`, `youtube.com`, etc. + * If this is set, it should be exactly matched with + * {@link google.cloud.retail.v2beta.UserEvent.entity|UserEvent.entity} to get + * search results boosted by entity. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 {@link google.cloud.retail.v2beta.SearchResponse.SearchResult | 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' + ] = this._gaxModule.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 Retail Search serving config, such as + * `projects/* /locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` + * or the name of the legacy placement resource, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. + * This field is used to identify the serving config 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.v2beta.SearchRequest.filter|filter} and + * {@link google.cloud.retail.v2beta.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.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 200 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 + * {@link google.cloud.retail.v2beta.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.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 google.cloud.retail.v2beta.LocalInventory.attributes|Product.local_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. Must be set 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, 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. + * + * Notice that if both + * {@link google.cloud.retail.v2beta.ServingConfig.personalization_spec|ServingConfig.personalization_spec} + * and + * {@link google.cloud.retail.v2beta.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * are set. + * {@link google.cloud.retail.v2beta.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * will override + * {@link google.cloud.retail.v2beta.ServingConfig.personalization_spec|ServingConfig.personalization_spec}. + * @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.v2beta.SearchRequest.SpellCorrectionSpec} request.spellCorrectionSpec + * The spell correction specification that specifies the mode under + * which spell correction will take effect. + * @param {string} request.entity + * The entity for customers that may run multiple different entities, domains, + * sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, + * `google.com`, `youtube.com`, etc. + * If this is set, it should be exactly matched with + * {@link google.cloud.retail.v2beta.UserEvent.entity|UserEvent.entity} to get + * search results boosted by entity. + * @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 {@link google.cloud.retail.v2beta.SearchResponse.SearchResult | 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' + ] = this._gaxModule.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 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 Retail Search serving config, such as + * `projects/* /locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` + * or the name of the legacy placement resource, such as + * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. + * This field is used to identify the serving config 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.v2beta.SearchRequest.filter|filter} and + * {@link google.cloud.retail.v2beta.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.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 200 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 + * {@link google.cloud.retail.v2beta.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.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 google.cloud.retail.v2beta.LocalInventory.attributes|Product.local_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. Must be set 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, 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. + * + * Notice that if both + * {@link google.cloud.retail.v2beta.ServingConfig.personalization_spec|ServingConfig.personalization_spec} + * and + * {@link google.cloud.retail.v2beta.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * are set. + * {@link google.cloud.retail.v2beta.SearchRequest.personalization_spec|SearchRequest.personalization_spec} + * will override + * {@link google.cloud.retail.v2beta.ServingConfig.personalization_spec|ServingConfig.personalization_spec}. + * @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.v2beta.SearchRequest.SpellCorrectionSpec} request.spellCorrectionSpec + * The spell correction specification that specifies the mode under + * which spell correction will take effect. + * @param {string} request.entity + * The entity for customers that may run multiple different entities, domains, + * sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, + * `google.com`, `youtube.com`, etc. + * If this is set, it should be exactly matched with + * {@link google.cloud.retail.v2beta.UserEvent.entity|UserEvent.entity} to get + * search results boosted by entity. + * @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 + * {@link google.cloud.retail.v2beta.SearchResponse.SearchResult | 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' + ] = this._gaxModule.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 {}, + callSettings + ) as AsyncIterable; + } +/** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + +/** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + +/** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified 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 experiment resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} experiment + * @returns {string} Resource name string. + */ + experimentPath(project:string,location:string,catalog:string,experiment:string) { + return this.pathTemplates.experimentPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + experiment: experiment, + }); + } + + /** + * Parse the project from Experiment resource. + * + * @param {string} experimentName + * A fully-qualified path representing Experiment resource. + * @returns {string} A string representing the project. + */ + matchProjectFromExperimentName(experimentName: string) { + return this.pathTemplates.experimentPathTemplate.match(experimentName).project; + } + + /** + * Parse the location from Experiment resource. + * + * @param {string} experimentName + * A fully-qualified path representing Experiment resource. + * @returns {string} A string representing the location. + */ + matchLocationFromExperimentName(experimentName: string) { + return this.pathTemplates.experimentPathTemplate.match(experimentName).location; + } + + /** + * Parse the catalog from Experiment resource. + * + * @param {string} experimentName + * A fully-qualified path representing Experiment resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromExperimentName(experimentName: string) { + return this.pathTemplates.experimentPathTemplate.match(experimentName).catalog; + } + + /** + * Parse the experiment from Experiment resource. + * + * @param {string} experimentName + * A fully-qualified path representing Experiment resource. + * @returns {string} A string representing the experiment. + */ + matchExperimentFromExperimentName(experimentName: string) { + return this.pathTemplates.experimentPathTemplate.match(experimentName).experiment; + } + + /** + * Return a fully-qualified model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project:string,location:string,catalog:string,model:string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * 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(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/search_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/search_service_client_config.json new file mode 100644 index 00000000000..82de0f81873 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2beta/src/v2beta/search_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/search_service_proto_list.json new file mode 100644 index 00000000000..ce2a33ebd29 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/search_service_proto_list.json @@ -0,0 +1,22 @@ +[ + "../../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/model.proto", + "../../protos/google/cloud/retail/v2beta/model_service.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/google-cloud-retail/v2beta/src/v2beta/serving_config_service_client.ts b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/serving_config_service_client.ts new file mode 100644 index 00000000000..6c869c15f11 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/serving_config_service_client.ts @@ -0,0 +1,1693 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/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}; + locationsClient: LocationsClient; + pathTemplates: {[name: string]: gax.PathTemplate}; + operationsClient: gax.OperationsClient; + 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/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new ServingConfigServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof 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); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + 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}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + 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') + }; + + const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',additional_bindings: [{get: '/v2beta/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2beta/{name=projects/*/locations/*/operations/*}',},{get: '/v2beta/{name=projects/*/operations/*}',}], + },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2beta/{name=projects/*/locations/*/catalogs/*}/operations',additional_bindings: [{get: '/v2beta/{name=projects/*/locations/*}/operations',},{get: '/v2beta/{name=projects/*}/operations',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + + this.descriptors.longrunning = { + }; + + // 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 = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.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._opts.fallback + ); + + 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 {@link google.cloud.retail.v2beta.ServingConfig | 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' + ] = this._gaxModule.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 {@link google.protobuf.Empty | 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' + ] = this._gaxModule.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 {@link google.cloud.retail.v2beta.ServingConfig | 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' + ] = this._gaxModule.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 {@link google.cloud.retail.v2beta.ServingConfig | 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' + ] = this._gaxModule.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 {@link google.cloud.retail.v2beta.ServingConfig | 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' + ] = this._gaxModule.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 {@link google.cloud.retail.v2beta.ServingConfig | 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' + ] = this._gaxModule.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 {@link google.cloud.retail.v2beta.ServingConfig | 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' + ] = this._gaxModule.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 {@link google.cloud.retail.v2beta.ServingConfig | 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' + ] = this._gaxModule.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 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 + * {@link google.cloud.retail.v2beta.ServingConfig | 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' + ] = this._gaxModule.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 {}, + callSettings + ) as AsyncIterable; + } +/** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + +/** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + +/** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified 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 model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project:string,location:string,catalog:string,model:string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * 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(); + this.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/serving_config_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/serving_config_service_client_config.json new file mode 100644 index 00000000000..2d17b5273c2 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2beta/src/v2beta/serving_config_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/serving_config_service_proto_list.json new file mode 100644 index 00000000000..ce2a33ebd29 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/serving_config_service_proto_list.json @@ -0,0 +1,22 @@ +[ + "../../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/model.proto", + "../../protos/google/cloud/retail/v2beta/model_service.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/google-cloud-retail/v2beta/src/v2beta/user_event_service_client.ts b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/user_event_service_client.ts new file mode 100644 index 00000000000..9cf218fd868 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/user_event_service_client.ts @@ -0,0 +1,1560 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import type * as gax from 'google-gax'; +import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, LocationsClient, LocationProtos} 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'; +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}; + locationsClient: LocationsClient; + 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/main/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. + * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. + * For more information, please check the + * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new UserEventServiceClient({fallback: 'rest'}, gax); + * ``` + */ + constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof 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); + + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + this.locationsClient = new this._gaxModule.LocationsClient( + this._gaxGrpc, + opts + ); + + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + 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}' + ), + modelPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' + ), + 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. + const lroOptions: GrpcClientOptions = { + auth: this.auth, + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + }; + if (opts.fallback === 'rest') { + lroOptions.protoJson = protoFilesRoot; + lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',additional_bindings: [{get: '/v2beta/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2beta/{name=projects/*/locations/*/operations/*}',},{get: '/v2beta/{name=projects/*/operations/*}',}], + },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2beta/{name=projects/*/locations/*/catalogs/*}/operations',additional_bindings: [{get: '/v2beta/{name=projects/*/locations/*}/operations',},{get: '/v2beta/{name=projects/*}/operations',}], + }]; + } + this.operationsClient = this._gaxModule.lro(lroOptions).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 = this._gaxModule.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.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._opts.fallback + ); + + 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 {boolean} request.writeAsync + * If set to true, the user event will be written asynchronously after + * validation, and the API will respond without waiting for the write. + * Therefore, silent failures can occur even if the API returns success. In + * case of silent failures, error messages can be found in Stackdriver logs. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.retail.v2beta.UserEvent | 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' + ] = this._gaxModule.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.prebuiltRule + * The prebuilt rule name that can convert a specific type of raw_json. + * For example: "ga4_bq" rule for the GA4 user event schema. + * @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 {string} request.rawJson + * An arbitrary serialized JSON string that contains necessary information + * that can comprise a user event. When this field is specified, the + * user_event field will be ignored. Note: line-delimited JSON is not + * supported, a single JSON only. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.api.HttpBody | 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' + ] = this._gaxModule.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' + ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.purgeUserEvents, this._gaxModule.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' + ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.importUserEvents, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Starts a user-event rejoin operation with latest product catalog. Events + * are not annotated with detailed product information for products that are + * missing from the catalog when the user event is ingested. These + * events are stored as unjoined events with limited usage on training and + * serving. You can use this method to start a join operation on specified + * events with the latest version of product catalog. You can also use this + * method 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' + ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.rejoinUserEvents, this._gaxModule.createDefaultBackoffSettings()); + return decodeOperation as LROperation; + } +/** + * Gets information about a location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Resource name for the location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * ``` + * const [response] = await client.getLocation(request); + * ``` + */ + getLocation( + request: LocationProtos.google.cloud.location.IGetLocationRequest, + options?: + | gax.CallOptions + | Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + LocationProtos.google.cloud.location.ILocation, + | LocationProtos.google.cloud.location.IGetLocationRequest + | null + | undefined, + {} | null | undefined + > + ): Promise { + return this.locationsClient.getLocation(request, options, callback); + } + +/** + * Lists information about the supported locations for this service. Returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The resource that owns the locations collection, if applicable. + * @param {string} request.filter + * The standard list filter. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * ``` + * const iterable = client.listLocationsAsync(request); + * for await (const response of iterable) { + * // process response + * } + * ``` + */ + listLocationsAsync( + request: LocationProtos.google.cloud.location.IListLocationsRequest, + options?: CallOptions + ): AsyncIterable { + return this.locationsClient.listLocationsAsync(request, options); + } + +/** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * {@link google.longrunning.Operation | google.longrunning.Operation}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See {@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} + * for the details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified 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 model resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} catalog + * @param {string} model + * @returns {string} Resource name string. + */ + modelPath(project:string,location:string,catalog:string,model:string) { + return this.pathTemplates.modelPathTemplate.render({ + project: project, + location: location, + catalog: catalog, + model: model, + }); + } + + /** + * Parse the project from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the project. + */ + matchProjectFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).project; + } + + /** + * Parse the location from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the location. + */ + matchLocationFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).location; + } + + /** + * Parse the catalog from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the catalog. + */ + matchCatalogFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).catalog; + } + + /** + * Parse the model from Model resource. + * + * @param {string} modelName + * A fully-qualified path representing Model resource. + * @returns {string} A string representing the model. + */ + matchModelFromModelName(modelName: string) { + return this.pathTemplates.modelPathTemplate.match(modelName).model; + } + + /** + * 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.locationsClient.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/user_event_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/user_event_service_client_config.json new file mode 100644 index 00000000000..f5bd2baedcc --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2beta/src/v2beta/user_event_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/user_event_service_proto_list.json new file mode 100644 index 00000000000..ce2a33ebd29 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/user_event_service_proto_list.json @@ -0,0 +1,22 @@ +[ + "../../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/model.proto", + "../../protos/google/cloud/retail/v2beta/model_service.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/google-cloud-retail/v2beta/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-retail/v2beta/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..b0a6d36778b --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/system-test/fixtures/sample/src/index.js @@ -0,0 +1,35 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 modelServiceClient = new retail.ModelServiceClient(); + 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/google-cloud-retail/v2beta/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-retail/v2beta/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..7ee871ea668 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,80 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This 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, ModelServiceClient, 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 doStuffWithModelServiceClient(client: ModelServiceClient) { + 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 modelServiceClient = new ModelServiceClient(); + doStuffWithModelServiceClient(modelServiceClient); + // 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/google-cloud-retail/v2beta/system-test/install.ts b/owl-bot-staging/google-cloud-retail/v2beta/system-test/install.ts new file mode 100644 index 00000000000..c8f81b25a86 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/system-test/install.ts @@ -0,0 +1,49 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {packNTest} from 'pack-n-play'; +import {readFileSync} from 'fs'; +import {describe, it} from 'mocha'; + +describe('📦 pack-n-play test', () => { + + it('TypeScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'TypeScript user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); + }); + + it('JavaScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'JavaScript user can use the library', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); + }); + +}); diff --git a/owl-bot-staging/google-cloud-retail/v2beta/test/gapic_catalog_service_v2beta.ts b/owl-bot-staging/google-cloud-retail/v2beta/test/gapic_catalog_service_v2beta.ts new file mode 100644 index 00000000000..43d47177d76 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/test/gapic_catalog_service_v2beta.ts @@ -0,0 +1,2520 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This 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, operationsProtos, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function 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', () => { + describe('Common methods', () => { + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateCatalogRequest', ['catalog', 'name']); + request.catalog.name = defaultValue1; + const expectedHeaderRequestParams = `catalog.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.updateCatalog as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateCatalog as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateCatalogRequest', ['catalog', 'name']); + request.catalog.name = defaultValue1; + const expectedHeaderRequestParams = `catalog.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.updateCatalog as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateCatalog as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateCatalogRequest', ['catalog', 'name']); + request.catalog.name = defaultValue1; + const expectedHeaderRequestParams = `catalog.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCatalog = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateCatalog(request), expectedError); + const actualRequest = (client.innerApiCalls.updateCatalog as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateCatalog as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateCatalogRequest', ['catalog', 'name']); + request.catalog.name = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.SetDefaultBranchRequest', ['catalog']); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.setDefaultBranch = stubSimpleCall(expectedResponse); + const [response] = await client.setDefaultBranch(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.setDefaultBranch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setDefaultBranch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.SetDefaultBranchRequest', ['catalog']); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.setDefaultBranch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setDefaultBranch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.SetDefaultBranchRequest', ['catalog']); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setDefaultBranch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setDefaultBranch(request), expectedError); + const actualRequest = (client.innerApiCalls.setDefaultBranch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setDefaultBranch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.SetDefaultBranchRequest', ['catalog']); + request.catalog = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.GetDefaultBranchRequest', ['catalog']); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getDefaultBranch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDefaultBranch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.GetDefaultBranchRequest', ['catalog']); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getDefaultBranch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDefaultBranch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.GetDefaultBranchRequest', ['catalog']); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getDefaultBranch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getDefaultBranch(request), expectedError); + const actualRequest = (client.innerApiCalls.getDefaultBranch as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getDefaultBranch as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.GetDefaultBranchRequest', ['catalog']); + request.catalog = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.GetCompletionConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getCompletionConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getCompletionConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.GetCompletionConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getCompletionConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getCompletionConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.GetCompletionConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getCompletionConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getCompletionConfig(request), expectedError); + const actualRequest = (client.innerApiCalls.getCompletionConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getCompletionConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.GetCompletionConfigRequest', ['name']); + request.name = defaultValue1; + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateCompletionConfigRequest', ['completionConfig', 'name']); + request.completionConfig.name = defaultValue1; + const expectedHeaderRequestParams = `completion_config.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.updateCompletionConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateCompletionConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateCompletionConfigRequest', ['completionConfig', 'name']); + request.completionConfig.name = defaultValue1; + const expectedHeaderRequestParams = `completion_config.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.updateCompletionConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateCompletionConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateCompletionConfigRequest', ['completionConfig', 'name']); + request.completionConfig.name = defaultValue1; + const expectedHeaderRequestParams = `completion_config.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCompletionConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateCompletionConfig(request), expectedError); + const actualRequest = (client.innerApiCalls.updateCompletionConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateCompletionConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateCompletionConfigRequest', ['completionConfig', 'name']); + request.completionConfig.name = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.GetAttributesConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getAttributesConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getAttributesConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.GetAttributesConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getAttributesConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getAttributesConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.GetAttributesConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getAttributesConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getAttributesConfig(request), expectedError); + const actualRequest = (client.innerApiCalls.getAttributesConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getAttributesConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.GetAttributesConfigRequest', ['name']); + request.name = defaultValue1; + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateAttributesConfigRequest', ['attributesConfig', 'name']); + request.attributesConfig.name = defaultValue1; + const expectedHeaderRequestParams = `attributes_config.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.updateAttributesConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateAttributesConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateAttributesConfigRequest', ['attributesConfig', 'name']); + request.attributesConfig.name = defaultValue1; + const expectedHeaderRequestParams = `attributes_config.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.updateAttributesConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateAttributesConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateAttributesConfigRequest', ['attributesConfig', 'name']); + request.attributesConfig.name = defaultValue1; + const expectedHeaderRequestParams = `attributes_config.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateAttributesConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateAttributesConfig(request), expectedError); + const actualRequest = (client.innerApiCalls.updateAttributesConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateAttributesConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateAttributesConfigRequest', ['attributesConfig', 'name']); + request.attributesConfig.name = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.AddCatalogAttributeRequest', ['attributesConfig']); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.addCatalogAttribute as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addCatalogAttribute as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.AddCatalogAttributeRequest', ['attributesConfig']); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.addCatalogAttribute as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addCatalogAttribute as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.AddCatalogAttributeRequest', ['attributesConfig']); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addCatalogAttribute = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.addCatalogAttribute(request), expectedError); + const actualRequest = (client.innerApiCalls.addCatalogAttribute as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addCatalogAttribute as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.AddCatalogAttributeRequest', ['attributesConfig']); + request.attributesConfig = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.RemoveCatalogAttributeRequest', ['attributesConfig']); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.removeCatalogAttribute as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeCatalogAttribute as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.RemoveCatalogAttributeRequest', ['attributesConfig']); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.removeCatalogAttribute as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeCatalogAttribute as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.RemoveCatalogAttributeRequest', ['attributesConfig']); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeCatalogAttribute = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.removeCatalogAttribute(request), expectedError); + const actualRequest = (client.innerApiCalls.removeCatalogAttribute as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeCatalogAttribute as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.RemoveCatalogAttributeRequest', ['attributesConfig']); + request.attributesConfig = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.removeCatalogAttribute(request), expectedError); + }); + }); + + describe('batchRemoveCatalogAttributes', () => { + it('invokes batchRemoveCatalogAttributes 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.BatchRemoveCatalogAttributesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest', ['attributesConfig']); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse() + ); + client.innerApiCalls.batchRemoveCatalogAttributes = stubSimpleCall(expectedResponse); + const [response] = await client.batchRemoveCatalogAttributes(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.batchRemoveCatalogAttributes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchRemoveCatalogAttributes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes batchRemoveCatalogAttributes 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.BatchRemoveCatalogAttributesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest', ['attributesConfig']); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse() + ); + client.innerApiCalls.batchRemoveCatalogAttributes = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchRemoveCatalogAttributes( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.batchRemoveCatalogAttributes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchRemoveCatalogAttributes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes batchRemoveCatalogAttributes 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.BatchRemoveCatalogAttributesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest', ['attributesConfig']); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.batchRemoveCatalogAttributes = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.batchRemoveCatalogAttributes(request), expectedError); + const actualRequest = (client.innerApiCalls.batchRemoveCatalogAttributes as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.batchRemoveCatalogAttributes as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes batchRemoveCatalogAttributes 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.BatchRemoveCatalogAttributesRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest', ['attributesConfig']); + request.attributesConfig = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.batchRemoveCatalogAttributes(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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest', ['attributesConfig']); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.replaceCatalogAttribute as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.replaceCatalogAttribute as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest', ['attributesConfig']); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.replaceCatalogAttribute as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.replaceCatalogAttribute as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest', ['attributesConfig']); + request.attributesConfig = defaultValue1; + const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.replaceCatalogAttribute = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.replaceCatalogAttribute(request), expectedError); + const actualRequest = (client.innerApiCalls.replaceCatalogAttribute as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.replaceCatalogAttribute as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest', ['attributesConfig']); + request.attributesConfig = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ListCatalogsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.listCatalogs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listCatalogs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ListCatalogsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.listCatalogs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listCatalogs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ListCatalogsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listCatalogs = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listCatalogs(request), expectedError); + const actualRequest = (client.innerApiCalls.listCatalogs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listCatalogs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ListCatalogsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listCatalogs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ListCatalogsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listCatalogs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ListCatalogsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ListCatalogsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getLocation without error using callback', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getLocation(request, expectedOptions), expectedError); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.getOperation(request)}, expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('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('model', () => { + const fakePath = "/rendered/path/model"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + model: "modelValue", + }; + const client = new catalogserviceModule.v2beta.CatalogServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.modelPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, "modelValue"); + assert((client.pathTemplates.modelPathTemplate.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/google-cloud-retail/v2beta/test/gapic_completion_service_v2beta.ts b/owl-bot-staging/google-cloud-retail/v2beta/test/gapic_completion_service_v2beta.ts new file mode 100644 index 00000000000..866250ab898 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/test/gapic_completion_service_v2beta.ts @@ -0,0 +1,1234 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This 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, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function 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.CompletionServiceClient', () => { + describe('Common methods', () => { + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.CompleteQueryRequest', ['catalog']); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.CompleteQueryRequest', ['catalog']); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.CompleteQueryRequest', ['catalog']); + request.catalog = defaultValue1; + const expectedHeaderRequestParams = `catalog=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.completeQuery = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.completeQuery(request), expectedError); + const actualRequest = (client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.completeQuery as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.CompleteQueryRequest', ['catalog']); + request.catalog = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ImportCompletionDataRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.importCompletionData as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importCompletionData as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ImportCompletionDataRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.importCompletionData as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importCompletionData as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ImportCompletionDataRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importCompletionData = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importCompletionData(request), expectedError); + const actualRequest = (client.innerApiCalls.importCompletionData as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importCompletionData as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ImportCompletionDataRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importCompletionData = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importCompletionData(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.importCompletionData as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importCompletionData as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getLocation without error using callback', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getLocation(request, expectedOptions), expectedError); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.getOperation(request)}, expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('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('model', () => { + const fakePath = "/rendered/path/model"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + model: "modelValue", + }; + const client = new completionserviceModule.v2beta.CompletionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.modelPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, "modelValue"); + assert((client.pathTemplates.modelPathTemplate.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/google-cloud-retail/v2beta/test/gapic_control_service_v2beta.ts b/owl-bot-staging/google-cloud-retail/v2beta/test/gapic_control_service_v2beta.ts new file mode 100644 index 00000000000..9628b75d93c --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/test/gapic_control_service_v2beta.ts @@ -0,0 +1,1664 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This 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, operationsProtos, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function 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', () => { + describe('Common methods', () => { + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.CreateControlRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.createControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.CreateControlRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.createControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.CreateControlRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createControl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createControl(request), expectedError); + const actualRequest = (client.innerApiCalls.createControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.CreateControlRequest', ['parent']); + request.parent = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.DeleteControlRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteControl = stubSimpleCall(expectedResponse); + const [response] = await client.deleteControl(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.DeleteControlRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.deleteControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.DeleteControlRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteControl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteControl(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.DeleteControlRequest', ['name']); + request.name = defaultValue1; + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateControlRequest', ['control', 'name']); + request.control.name = defaultValue1; + const expectedHeaderRequestParams = `control.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.updateControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateControlRequest', ['control', 'name']); + request.control.name = defaultValue1; + const expectedHeaderRequestParams = `control.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.updateControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateControlRequest', ['control', 'name']); + request.control.name = defaultValue1; + const expectedHeaderRequestParams = `control.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateControl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateControl(request), expectedError); + const actualRequest = (client.innerApiCalls.updateControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateControlRequest', ['control', 'name']); + request.control.name = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.GetControlRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.GetControlRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.GetControlRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getControl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getControl(request), expectedError); + const actualRequest = (client.innerApiCalls.getControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.GetControlRequest', ['name']); + request.name = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ListControlsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.listControls as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listControls as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ListControlsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.listControls as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listControls as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ListControlsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listControls = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listControls(request), expectedError); + const actualRequest = (client.innerApiCalls.listControls as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listControls as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ListControlsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listControls.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ListControlsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listControls.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ListControlsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listControls.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ListControlsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listControls.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getLocation without error using callback', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getLocation(request, expectedOptions), expectedError); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.getOperation(request)}, expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('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('model', () => { + const fakePath = "/rendered/path/model"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + model: "modelValue", + }; + const client = new controlserviceModule.v2beta.ControlServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.modelPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, "modelValue"); + assert((client.pathTemplates.modelPathTemplate.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/google-cloud-retail/v2beta/test/gapic_model_service_v2beta.ts b/owl-bot-staging/google-cloud-retail/v2beta/test/gapic_model_service_v2beta.ts new file mode 100644 index 00000000000..ba13b0eaa9a --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/test/gapic_model_service_v2beta.ts @@ -0,0 +1,2096 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This 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 modelserviceModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v2beta.ModelServiceClient', () => { + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = modelserviceModule.v2beta.ModelServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = modelserviceModule.v2beta.ModelServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = modelserviceModule.v2beta.ModelServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new modelserviceModule.v2beta.ModelServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.modelServiceStub, undefined); + await client.initialize(); + assert(client.modelServiceStub); + }); + + it('has close method for the initialized client', done => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.modelServiceStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.modelServiceStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new modelserviceModule.v2beta.ModelServiceClient({ + 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 modelserviceModule.v2beta.ModelServiceClient({ + 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('getModel', () => { + it('invokes getModel without error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.GetModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.GetModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.Model() + ); + client.innerApiCalls.getModel = stubSimpleCall(expectedResponse); + const [response] = await client.getModel(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getModel without error using callback', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.GetModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.GetModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.Model() + ); + client.innerApiCalls.getModel = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getModel( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IModel|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getModel with error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.GetModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.GetModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getModel = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getModel(request), expectedError); + const actualRequest = (client.innerApiCalls.getModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getModel with closed client', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.GetModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.GetModelRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getModel(request), expectedError); + }); + }); + + describe('pauseModel', () => { + it('invokes pauseModel without error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.PauseModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.PauseModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.Model() + ); + client.innerApiCalls.pauseModel = stubSimpleCall(expectedResponse); + const [response] = await client.pauseModel(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.pauseModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.pauseModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pauseModel without error using callback', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.PauseModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.PauseModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.Model() + ); + client.innerApiCalls.pauseModel = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.pauseModel( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IModel|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.pauseModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.pauseModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pauseModel with error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.PauseModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.PauseModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.pauseModel = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.pauseModel(request), expectedError); + const actualRequest = (client.innerApiCalls.pauseModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.pauseModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pauseModel with closed client', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.PauseModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.PauseModelRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.pauseModel(request), expectedError); + }); + }); + + describe('resumeModel', () => { + it('invokes resumeModel without error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ResumeModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ResumeModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.Model() + ); + client.innerApiCalls.resumeModel = stubSimpleCall(expectedResponse); + const [response] = await client.resumeModel(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.resumeModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resumeModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resumeModel without error using callback', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ResumeModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ResumeModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.Model() + ); + client.innerApiCalls.resumeModel = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.resumeModel( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IModel|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.resumeModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resumeModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resumeModel with error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ResumeModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ResumeModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resumeModel = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.resumeModel(request), expectedError); + const actualRequest = (client.innerApiCalls.resumeModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.resumeModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resumeModel with closed client', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ResumeModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ResumeModelRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.resumeModel(request), expectedError); + }); + }); + + describe('deleteModel', () => { + it('invokes deleteModel without error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.DeleteModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.DeleteModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteModel = stubSimpleCall(expectedResponse); + const [response] = await client.deleteModel(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteModel without error using callback', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.DeleteModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.DeleteModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteModel = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteModel( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteModel with error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.DeleteModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.DeleteModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteModel = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteModel(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteModel with closed client', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.DeleteModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.DeleteModelRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteModel(request), expectedError); + }); + }); + + describe('updateModel', () => { + it('invokes updateModel without error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.UpdateModelRequest() + ); + request.model ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateModelRequest', ['model', 'name']); + request.model.name = defaultValue1; + const expectedHeaderRequestParams = `model.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.Model() + ); + client.innerApiCalls.updateModel = stubSimpleCall(expectedResponse); + const [response] = await client.updateModel(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateModel without error using callback', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.UpdateModelRequest() + ); + request.model ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateModelRequest', ['model', 'name']); + request.model.name = defaultValue1; + const expectedHeaderRequestParams = `model.name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.retail.v2beta.Model() + ); + client.innerApiCalls.updateModel = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateModel( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IModel|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.updateModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateModel with error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.UpdateModelRequest() + ); + request.model ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateModelRequest', ['model', 'name']); + request.model.name = defaultValue1; + const expectedHeaderRequestParams = `model.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateModel = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateModel(request), expectedError); + const actualRequest = (client.innerApiCalls.updateModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateModel with closed client', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.UpdateModelRequest() + ); + request.model ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateModelRequest', ['model', 'name']); + request.model.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateModel(request), expectedError); + }); + }); + + describe('createModel', () => { + it('invokes createModel without error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.CreateModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.CreateModelRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createModel = stubLongRunningCall(expectedResponse); + const [operation] = await client.createModel(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createModel without error using callback', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.CreateModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.CreateModelRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createModel = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createModel( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.createModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createModel with call error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.CreateModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.CreateModelRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createModel = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.createModel(request), expectedError); + const actualRequest = (client.innerApiCalls.createModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createModel with LRO error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.CreateModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.CreateModelRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createModel = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createModel(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.createModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateModelProgress without error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateModelProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateModelProgress with error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkCreateModelProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('tuneModel', () => { + it('invokes tuneModel without error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.TuneModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.TuneModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.tuneModel = stubLongRunningCall(expectedResponse); + const [operation] = await client.tuneModel(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.tuneModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.tuneModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes tuneModel without error using callback', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.TuneModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.TuneModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.tuneModel = stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.tuneModel( + request, + (err?: Error|null, + result?: LROperation|null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const operation = await promise as LROperation; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.tuneModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.tuneModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes tuneModel with call error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.TuneModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.TuneModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.tuneModel = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.tuneModel(request), expectedError); + const actualRequest = (client.innerApiCalls.tuneModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.tuneModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes tuneModel with LRO error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.TuneModelRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.TuneModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.tuneModel = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.tuneModel(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.tuneModel as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.tuneModel as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkTuneModelProgress without error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkTuneModelProgress(expectedResponse.name); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkTuneModelProgress with error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.checkTuneModelProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + }); + + describe('listModels', () => { + it('invokes listModels without error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListModelsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ListModelsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.Model()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Model()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Model()), + ]; + client.innerApiCalls.listModels = stubSimpleCall(expectedResponse); + const [response] = await client.listModels(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listModels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listModels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listModels without error using callback', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListModelsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ListModelsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.Model()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Model()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Model()), + ]; + client.innerApiCalls.listModels = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listModels( + request, + (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IModel[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.listModels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listModels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listModels with error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListModelsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ListModelsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listModels = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listModels(request), expectedError); + const actualRequest = (client.innerApiCalls.listModels as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listModels as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listModelsStream without error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListModelsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ListModelsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.Model()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Model()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Model()), + ]; + client.descriptors.page.listModels.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listModelsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2beta.Model[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2beta.Model) => { + 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.listModels.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listModels, request)); + assert( + (client.descriptors.page.listModels.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listModelsStream with error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListModelsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ListModelsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listModels.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listModelsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.retail.v2beta.Model[] = []; + stream.on('data', (response: protos.google.cloud.retail.v2beta.Model) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listModels.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listModels, request)); + assert( + (client.descriptors.page.listModels.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listModels without error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListModelsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ListModelsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.retail.v2beta.Model()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Model()), + generateSampleMessage(new protos.google.cloud.retail.v2beta.Model()), + ]; + client.descriptors.page.listModels.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.retail.v2beta.IModel[] = []; + const iterable = client.listModelsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listModels.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listModels.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listModels with error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListModelsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ListModelsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listModels.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listModelsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.retail.v2beta.IModel[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listModels.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.descriptors.page.listModels.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getLocation without error using callback', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getLocation(request, expectedOptions), expectedError); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.getOperation(request)}, expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('attributesConfig', () => { + const fakePath = "/rendered/path/attributesConfig"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + }; + const client = new modelserviceModule.v2beta.ModelServiceClient({ + 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 modelserviceModule.v2beta.ModelServiceClient({ + 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 modelserviceModule.v2beta.ModelServiceClient({ + 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 modelserviceModule.v2beta.ModelServiceClient({ + 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('model', () => { + const fakePath = "/rendered/path/model"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + model: "modelValue", + }; + const client = new modelserviceModule.v2beta.ModelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.modelPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, "modelValue"); + assert((client.pathTemplates.modelPathTemplate.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 modelserviceModule.v2beta.ModelServiceClient({ + 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 modelserviceModule.v2beta.ModelServiceClient({ + 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/google-cloud-retail/v2beta/test/gapic_prediction_service_v2beta.ts b/owl-bot-staging/google-cloud-retail/v2beta/test/gapic_prediction_service_v2beta.ts new file mode 100644 index 00000000000..22417c9549c --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/test/gapic_prediction_service_v2beta.ts @@ -0,0 +1,1064 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This 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, operationsProtos, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function 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.PredictionServiceClient', () => { + describe('Common methods', () => { + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.PredictRequest', ['placement']); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.predict as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.predict as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.PredictRequest', ['placement']); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.predict as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.predict as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.PredictRequest', ['placement']); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.predict = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.predict(request), expectedError); + const actualRequest = (client.innerApiCalls.predict as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.predict as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.PredictRequest', ['placement']); + request.placement = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.predict(request), expectedError); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getLocation without error using callback', async () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getLocation(request, expectedOptions), expectedError); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.getOperation(request)}, expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('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('model', () => { + const fakePath = "/rendered/path/model"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + model: "modelValue", + }; + const client = new predictionserviceModule.v2beta.PredictionServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.modelPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, "modelValue"); + assert((client.pathTemplates.modelPathTemplate.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/google-cloud-retail/v2beta/test/gapic_product_service_v2beta.ts b/owl-bot-staging/google-cloud-retail/v2beta/test/gapic_product_service_v2beta.ts new file mode 100644 index 00000000000..c0863b36007 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/test/gapic_product_service_v2beta.ts @@ -0,0 +1,2662 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This 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, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v2beta.ProductServiceClient', () => { + describe('Common methods', () => { + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.CreateProductRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProduct without error using callback', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.CreateProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.CreateProductRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProduct with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.CreateProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.CreateProductRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createProduct(request), expectedError); + const actualRequest = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProduct with closed client', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.CreateProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.CreateProductRequest', ['parent']); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createProduct(request), expectedError); + }); + }); + + describe('getProduct', () => { + it('invokes getProduct without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.GetProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProduct without error using callback', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.GetProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProduct with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.GetProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getProduct(request), expectedError); + const actualRequest = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProduct with closed client', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.GetProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.GetProductRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getProduct(request), expectedError); + }); + }); + + describe('updateProduct', () => { + it('invokes updateProduct without error', async () => { + const client = new 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateProductRequest', ['product', 'name']); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProduct without error using callback', async () => { + const client = new 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateProductRequest', ['product', 'name']); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProduct with error', async () => { + const client = new 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateProductRequest', ['product', 'name']); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateProduct(request), expectedError); + const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateProduct with closed client', async () => { + const client = new 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateProductRequest', ['product', 'name']); + request.product.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateProduct(request), expectedError); + }); + }); + + describe('deleteProduct', () => { + it('invokes deleteProduct without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.DeleteProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.DeleteProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteProduct = stubSimpleCall(expectedResponse); + const [response] = await client.deleteProduct(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProduct without error using callback', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.DeleteProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.DeleteProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteProduct = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteProduct( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProduct with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.DeleteProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.DeleteProductRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProduct = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteProduct(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteProduct with closed client', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.DeleteProductRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.DeleteProductRequest', ['name']); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteProduct(request), expectedError); + }); + }); + + describe('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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ImportProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.importProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ImportProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.importProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ImportProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importProducts = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importProducts(request), expectedError); + const actualRequest = (client.innerApiCalls.importProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ImportProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importProducts = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importProducts(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.importProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.SetInventoryRequest', ['inventory', 'name']); + request.inventory.name = defaultValue1; + const expectedHeaderRequestParams = `inventory.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.setInventory as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setInventory as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.SetInventoryRequest', ['inventory', 'name']); + request.inventory.name = defaultValue1; + const expectedHeaderRequestParams = `inventory.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.setInventory as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setInventory as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.SetInventoryRequest', ['inventory', 'name']); + request.inventory.name = defaultValue1; + const expectedHeaderRequestParams = `inventory.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setInventory = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.setInventory(request), expectedError); + const actualRequest = (client.innerApiCalls.setInventory as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setInventory as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.SetInventoryRequest', ['inventory', 'name']); + request.inventory.name = defaultValue1; + const expectedHeaderRequestParams = `inventory.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setInventory = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.setInventory(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.setInventory as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.setInventory as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.AddFulfillmentPlacesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.AddFulfillmentPlacesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.AddFulfillmentPlacesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.addFulfillmentPlaces(request), expectedError); + const actualRequest = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.AddFulfillmentPlacesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.addFulfillmentPlaces(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.removeFulfillmentPlaces(request), expectedError); + const actualRequest = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.removeFulfillmentPlaces(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.AddLocalInventoriesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.addLocalInventories as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addLocalInventories as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.AddLocalInventoriesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.addLocalInventories as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addLocalInventories as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.AddLocalInventoriesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addLocalInventories = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.addLocalInventories(request), expectedError); + const actualRequest = (client.innerApiCalls.addLocalInventories as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addLocalInventories as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.AddLocalInventoriesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addLocalInventories = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.addLocalInventories(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.addLocalInventories as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addLocalInventories as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.RemoveLocalInventoriesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.removeLocalInventories as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeLocalInventories as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.RemoveLocalInventoriesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.removeLocalInventories as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeLocalInventories as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.RemoveLocalInventoriesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeLocalInventories = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.removeLocalInventories(request), expectedError); + const actualRequest = (client.innerApiCalls.removeLocalInventories as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeLocalInventories as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.RemoveLocalInventoriesRequest', ['product']); + request.product = defaultValue1; + const expectedHeaderRequestParams = `product=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeLocalInventories = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.removeLocalInventories(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.removeLocalInventories as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeLocalInventories as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProducts without error using callback', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProducts with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listProducts = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listProducts(request), expectedError); + const actualRequest = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProductsStream without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('invokes listProductsStream with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProducts.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listProductsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.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( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProducts without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + + it('uses async iteration with listProducts with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.retail.v2beta.ListProductsRequest() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ListProductsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProductsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.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( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getLocation without error using callback', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getLocation(request, expectedOptions), expectedError); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.getOperation(request)}, expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('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('model', () => { + const fakePath = "/rendered/path/model"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + model: "modelValue", + }; + const client = new productserviceModule.v2beta.ProductServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.modelPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, "modelValue"); + assert((client.pathTemplates.modelPathTemplate.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/google-cloud-retail/v2beta/test/gapic_search_service_v2beta.ts b/owl-bot-staging/google-cloud-retail/v2beta/test/gapic_search_service_v2beta.ts new file mode 100644 index 00000000000..38621620329 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/test/gapic_search_service_v2beta.ts @@ -0,0 +1,1336 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This 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, operationsProtos, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function 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', () => { + describe('Common methods', () => { + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.SearchRequest', ['placement']); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.search as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.search as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.SearchRequest', ['placement']); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.search as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.search as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.SearchRequest', ['placement']); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.search = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.search(request), expectedError); + const actualRequest = (client.innerApiCalls.search as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.search as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.SearchRequest', ['placement']); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + 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( + (client.descriptors.page.search.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.SearchRequest', ['placement']); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + 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( + (client.descriptors.page.search.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.SearchRequest', ['placement']); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + 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( + (client.descriptors.page.search.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.SearchRequest', ['placement']); + request.placement = defaultValue1; + const expectedHeaderRequestParams = `placement=${defaultValue1}`; + 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( + (client.descriptors.page.search.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getLocation without error using callback', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getLocation(request, expectedOptions), expectedError); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.getOperation(request)}, expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('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('experiment', () => { + const fakePath = "/rendered/path/experiment"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + experiment: "experimentValue", + }; + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.experimentPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.experimentPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('experimentPath', () => { + const result = client.experimentPath("projectValue", "locationValue", "catalogValue", "experimentValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.experimentPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromExperimentName', () => { + const result = client.matchProjectFromExperimentName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.experimentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromExperimentName', () => { + const result = client.matchLocationFromExperimentName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.experimentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromExperimentName', () => { + const result = client.matchCatalogFromExperimentName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.experimentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchExperimentFromExperimentName', () => { + const result = client.matchExperimentFromExperimentName(fakePath); + assert.strictEqual(result, "experimentValue"); + assert((client.pathTemplates.experimentPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('model', () => { + const fakePath = "/rendered/path/model"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + model: "modelValue", + }; + const client = new searchserviceModule.v2beta.SearchServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.modelPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, "modelValue"); + assert((client.pathTemplates.modelPathTemplate.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/google-cloud-retail/v2beta/test/gapic_serving_config_service_v2beta.ts b/owl-bot-staging/google-cloud-retail/v2beta/test/gapic_serving_config_service_v2beta.ts new file mode 100644 index 00000000000..7340f88515e --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/test/gapic_serving_config_service_v2beta.ts @@ -0,0 +1,1880 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This 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, operationsProtos, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function 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', () => { + describe('Common methods', () => { + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.CreateServingConfigRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.createServingConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createServingConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.CreateServingConfigRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.createServingConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createServingConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.CreateServingConfigRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createServingConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createServingConfig(request), expectedError); + const actualRequest = (client.innerApiCalls.createServingConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.createServingConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.CreateServingConfigRequest', ['parent']); + request.parent = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.DeleteServingConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteServingConfig = stubSimpleCall(expectedResponse); + const [response] = await client.deleteServingConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.deleteServingConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteServingConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.DeleteServingConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.deleteServingConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteServingConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.DeleteServingConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteServingConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteServingConfig(request), expectedError); + const actualRequest = (client.innerApiCalls.deleteServingConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.deleteServingConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.DeleteServingConfigRequest', ['name']); + request.name = defaultValue1; + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateServingConfigRequest', ['servingConfig', 'name']); + request.servingConfig.name = defaultValue1; + const expectedHeaderRequestParams = `serving_config.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.updateServingConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateServingConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateServingConfigRequest', ['servingConfig', 'name']); + request.servingConfig.name = defaultValue1; + const expectedHeaderRequestParams = `serving_config.name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.updateServingConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateServingConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateServingConfigRequest', ['servingConfig', 'name']); + request.servingConfig.name = defaultValue1; + const expectedHeaderRequestParams = `serving_config.name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateServingConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateServingConfig(request), expectedError); + const actualRequest = (client.innerApiCalls.updateServingConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.updateServingConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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 ??= {}; + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateServingConfigRequest', ['servingConfig', 'name']); + request.servingConfig.name = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.GetServingConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getServingConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getServingConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.GetServingConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.getServingConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getServingConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.GetServingConfigRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getServingConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getServingConfig(request), expectedError); + const actualRequest = (client.innerApiCalls.getServingConfig as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.getServingConfig as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.GetServingConfigRequest', ['name']); + request.name = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.AddControlRequest', ['servingConfig']); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.addControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.AddControlRequest', ['servingConfig']); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.addControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.AddControlRequest', ['servingConfig']); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addControl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.addControl(request), expectedError); + const actualRequest = (client.innerApiCalls.addControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.addControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.AddControlRequest', ['servingConfig']); + request.servingConfig = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.RemoveControlRequest', ['servingConfig']); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.removeControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.RemoveControlRequest', ['servingConfig']); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.removeControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.RemoveControlRequest', ['servingConfig']); + request.servingConfig = defaultValue1; + const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removeControl = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.removeControl(request), expectedError); + const actualRequest = (client.innerApiCalls.removeControl as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.removeControl as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.RemoveControlRequest', ['servingConfig']); + request.servingConfig = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ListServingConfigsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.listServingConfigs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listServingConfigs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ListServingConfigsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); + const actualRequest = (client.innerApiCalls.listServingConfigs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listServingConfigs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ListServingConfigsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listServingConfigs = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listServingConfigs(request), expectedError); + const actualRequest = (client.innerApiCalls.listServingConfigs as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.listServingConfigs as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ListServingConfigsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listServingConfigs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ListServingConfigsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listServingConfigs.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ListServingConfigsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ListServingConfigsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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( + (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getLocation without error using callback', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getLocation(request, expectedOptions), expectedError); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.getOperation(request)}, expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('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('model', () => { + const fakePath = "/rendered/path/model"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + model: "modelValue", + }; + const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.modelPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, "modelValue"); + assert((client.pathTemplates.modelPathTemplate.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/google-cloud-retail/v2beta/test/gapic_user_event_service_v2beta.ts b/owl-bot-staging/google-cloud-retail/v2beta/test/gapic_user_event_service_v2beta.ts new file mode 100644 index 00000000000..5962210be60 --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/v2beta/test/gapic_user_event_service_v2beta.ts @@ -0,0 +1,1650 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This 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, LocationProtos} from 'google-gax'; + +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +} + +function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { + const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +} + +function 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.UserEventServiceClient', () => { + describe('Common methods', () => { + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.WriteUserEventRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.WriteUserEventRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.WriteUserEventRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.writeUserEvent = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.writeUserEvent(request), expectedError); + const actualRequest = (client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.writeUserEvent as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.WriteUserEventRequest', ['parent']); + request.parent = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.CollectUserEventRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.api.HttpBody() + ); + client.innerApiCalls.collectUserEvent = stubSimpleCall(expectedResponse); + const [response] = await client.collectUserEvent(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.CollectUserEventRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.CollectUserEventRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.collectUserEvent = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.collectUserEvent(request), expectedError); + const actualRequest = (client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.collectUserEvent as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.CollectUserEventRequest', ['parent']); + request.parent = defaultValue1; + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.PurgeUserEventsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.purgeUserEvents as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.purgeUserEvents as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.PurgeUserEventsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.purgeUserEvents as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.purgeUserEvents as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.PurgeUserEventsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeUserEvents = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.purgeUserEvents(request), expectedError); + const actualRequest = (client.innerApiCalls.purgeUserEvents as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.purgeUserEvents as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.PurgeUserEventsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeUserEvents = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.purgeUserEvents(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.purgeUserEvents as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.purgeUserEvents as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ImportUserEventsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ImportUserEventsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ImportUserEventsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importUserEvents = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.importUserEvents(request), expectedError); + const actualRequest = (client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.ImportUserEventsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importUserEvents = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.importUserEvents(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.importUserEvents as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.RejoinUserEventsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.rejoinUserEvents as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.rejoinUserEvents as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.RejoinUserEventsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + 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); + const actualRequest = (client.innerApiCalls.rejoinUserEvents as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.rejoinUserEvents as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.RejoinUserEventsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(undefined, expectedError); + await assert.rejects(client.rejoinUserEvents(request), expectedError); + const actualRequest = (client.innerApiCalls.rejoinUserEvents as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.rejoinUserEvents as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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() + ); + const defaultValue1 = + getTypeDefaultValue('.google.cloud.retail.v2beta.RejoinUserEventsRequest', ['parent']); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.rejoinUserEvents(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = (client.innerApiCalls.rejoinUserEvents as SinonStub) + .getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = (client.innerApiCalls.rejoinUserEvents as SinonStub) + .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + 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('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + it('invokes getLocation without error using callback', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getLocation(request, expectedOptions), expectedError); + assert((client.locationsClient.getLocation as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert( + (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.getOperation(request)}, expectedError); + assert((client.operationsClient.getOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); + assert((client.operationsClient.cancelOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); + assert((client.operationsClient.deleteOperation as SinonStub) + .getCall(0).calledWith(request)); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + + describe('Path templates', () => { + + describe('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('model', () => { + const fakePath = "/rendered/path/model"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + catalog: "catalogValue", + model: "modelValue", + }; + const client = new usereventserviceModule.v2beta.UserEventServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.modelPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.modelPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('modelPath', () => { + const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.modelPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromModelName', () => { + const result = client.matchProjectFromModelName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromModelName', () => { + const result = client.matchLocationFromModelName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchCatalogFromModelName', () => { + const result = client.matchCatalogFromModelName(fakePath); + assert.strictEqual(result, "catalogValue"); + assert((client.pathTemplates.modelPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchModelFromModelName', () => { + const result = client.matchModelFromModelName(fakePath); + assert.strictEqual(result, "modelValue"); + assert((client.pathTemplates.modelPathTemplate.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/google-cloud-retail/v2beta/tsconfig.json b/owl-bot-staging/google-cloud-retail/v2beta/tsconfig.json new file mode 100644 index 00000000000..c78f1c884ef --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2beta/webpack.config.js b/owl-bot-staging/google-cloud-retail/v2beta/webpack.config.js new file mode 100644 index 00000000000..f2c58f2530c --- /dev/null +++ b/owl-bot-staging/google-cloud-retail/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 fe16054519d990bb62200249e1d3824589547057 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Mon, 17 Apr 2023 20:18:00 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20po?= =?UTF-8?q?st-processor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- .../google-cloud-retail/v2/.eslintignore | 7 - .../google-cloud-retail/v2/.eslintrc.json | 3 - .../google-cloud-retail/v2/.gitignore | 14 - .../google-cloud-retail/v2/.jsdoc.js | 55 - .../google-cloud-retail/v2/.mocharc.js | 33 - .../google-cloud-retail/v2/.prettierrc.js | 22 - .../google-cloud-retail/v2/README.md | 1 - .../v2/linkinator.config.json | 16 - .../google-cloud-retail/v2/package.json | 72 - .../google/cloud/retail/v2/catalog.proto | 393 --- .../cloud/retail/v2/catalog_service.proto | 476 --- .../google/cloud/retail/v2/common.proto | 782 ---- .../cloud/retail/v2/completion_service.proto | 220 -- .../google/cloud/retail/v2/control.proto | 92 - .../cloud/retail/v2/control_service.proto | 185 - .../cloud/retail/v2/import_config.proto | 386 -- .../protos/google/cloud/retail/v2/model.proto | 239 -- .../cloud/retail/v2/model_service.proto | 262 -- .../cloud/retail/v2/prediction_service.proto | 226 -- .../google/cloud/retail/v2/product.proto | 586 --- .../cloud/retail/v2/product_service.proto | 921 ----- .../google/cloud/retail/v2/promotion.proto | 40 - .../google/cloud/retail/v2/purge_config.proto | 82 - .../cloud/retail/v2/search_service.proto | 985 ------ .../cloud/retail/v2/serving_config.proto | 265 -- .../retail/v2/serving_config_service.proto | 240 -- .../google/cloud/retail/v2/user_event.proto | 350 -- .../cloud/retail/v2/user_event_service.proto | 210 -- .../catalog_service.add_catalog_attribute.js | 68 - .../catalog_service.get_attributes_config.js | 62 - .../catalog_service.get_completion_config.js | 62 - .../v2/catalog_service.get_default_branch.js | 61 - .../v2/catalog_service.list_catalogs.js | 86 - ...atalog_service.remove_catalog_attribute.js | 68 - ...talog_service.replace_catalog_attribute.js | 76 - .../v2/catalog_service.set_default_branch.js | 84 - ...atalog_service.update_attributes_config.js | 70 - .../v2/catalog_service.update_catalog.js | 73 - ...atalog_service.update_completion_config.js | 78 - .../v2/completion_service.complete_query.js | 132 - ...mpletion_service.import_completion_data.js | 76 - .../v2/control_service.create_control.js | 75 - .../v2/control_service.delete_control.js | 62 - .../v2/control_service.get_control.js | 62 - .../v2/control_service.list_controls.js | 82 - .../v2/control_service.update_control.js | 69 - .../v2/model_service.create_model.js | 74 - .../v2/model_service.delete_model.js | 63 - .../generated/v2/model_service.get_model.js | 63 - .../generated/v2/model_service.list_models.js | 75 - .../generated/v2/model_service.pause_model.js | 63 - .../v2/model_service.resume_model.js | 63 - .../generated/v2/model_service.tune_model.js | 64 - .../v2/model_service.update_model.js | 66 - .../v2/prediction_service.predict.js | 187 - .../product_service.add_fulfillment_places.js | 119 - .../product_service.add_local_inventories.js | 102 - .../v2/product_service.create_product.js | 83 - .../v2/product_service.delete_product.js | 77 - .../v2/product_service.get_product.js | 68 - .../v2/product_service.import_products.js | 98 - .../v2/product_service.list_products.js | 133 - ...oduct_service.remove_fulfillment_places.js | 115 - ...roduct_service.remove_local_inventories.js | 88 - .../v2/product_service.set_inventory.js | 131 - .../v2/product_service.update_product.js | 87 - .../generated/v2/search_service.search.js | 312 -- .../v2/serving_config_service.add_control.js | 68 - ...ng_config_service.create_serving_config.js | 75 - ...ng_config_service.delete_serving_config.js | 62 - ...rving_config_service.get_serving_config.js | 62 - ...ing_config_service.list_serving_configs.js | 75 - .../serving_config_service.remove_control.js | 68 - ...ng_config_service.update_serving_config.js | 69 - ...ippet_metadata.google.cloud.retail.v2.json | 2499 ------------- .../user_event_service.collect_user_event.js | 93 - .../user_event_service.import_user_events.js | 72 - .../user_event_service.purge_user_events.js | 93 - .../user_event_service.rejoin_user_events.js | 70 - .../v2/user_event_service.write_user_event.js | 74 - .../google-cloud-retail/v2/src/index.ts | 41 - .../v2/src/v2/catalog_service_client.ts | 2223 ------------ .../src/v2/catalog_service_client_config.json | 90 - .../v2/src/v2/catalog_service_proto_list.json | 21 - .../v2/src/v2/completion_service_client.ts | 1294 ------- .../v2/completion_service_client_config.json | 45 - .../src/v2/completion_service_proto_list.json | 21 - .../v2/src/v2/control_service_client.ts | 1556 -------- .../src/v2/control_service_client_config.json | 46 - .../v2/src/v2/control_service_proto_list.json | 21 - .../v2/src/v2/gapic_metadata.json | 669 ---- .../google-cloud-retail/v2/src/v2/index.ts | 27 - .../v2/src/v2/model_service_client.ts | 1811 ---------- .../src/v2/model_service_client_config.json | 66 - .../v2/src/v2/model_service_proto_list.json | 21 - .../v2/src/v2/prediction_service_client.ts | 1226 ------- .../v2/prediction_service_client_config.json | 40 - .../src/v2/prediction_service_proto_list.json | 21 - .../v2/src/v2/product_service_client.ts | 2857 --------------- .../src/v2/product_service_client_config.json | 99 - .../v2/src/v2/product_service_proto_list.json | 21 - .../v2/src/v2/search_service_client.ts | 2043 ----------- .../src/v2/search_service_client_config.json | 40 - .../v2/src/v2/search_service_proto_list.json | 21 - .../src/v2/serving_config_service_client.ts | 1693 --------- .../serving_config_service_client_config.json | 54 - .../v2/serving_config_service_proto_list.json | 21 - .../v2/src/v2/user_event_service_client.ts | 1559 -------- .../v2/user_event_service_client_config.json | 78 - .../src/v2/user_event_service_proto_list.json | 21 - .../system-test/fixtures/sample/src/index.js | 35 - .../system-test/fixtures/sample/src/index.ts | 80 - .../v2/system-test/install.ts | 49 - .../v2/test/gapic_catalog_service_v2.ts | 2412 ------------- .../v2/test/gapic_completion_service_v2.ts | 1234 ------- .../v2/test/gapic_control_service_v2.ts | 1664 --------- .../v2/test/gapic_model_service_v2.ts | 2096 ----------- .../v2/test/gapic_prediction_service_v2.ts | 1064 ------ .../v2/test/gapic_product_service_v2.ts | 2662 -------------- .../v2/test/gapic_search_service_v2.ts | 1336 ------- .../test/gapic_serving_config_service_v2.ts | 1880 ---------- .../v2/test/gapic_user_event_service_v2.ts | 1650 --------- .../google-cloud-retail/v2/tsconfig.json | 19 - .../google-cloud-retail/v2/webpack.config.js | 64 - .../google-cloud-retail/v2alpha/.eslintignore | 7 - .../v2alpha/.eslintrc.json | 3 - .../google-cloud-retail/v2alpha/.gitignore | 14 - .../google-cloud-retail/v2alpha/.jsdoc.js | 55 - .../google-cloud-retail/v2alpha/.mocharc.js | 33 - .../v2alpha/.prettierrc.js | 22 - .../google-cloud-retail/v2alpha/README.md | 1 - .../v2alpha/linkinator.config.json | 16 - .../google-cloud-retail/v2alpha/package.json | 73 - .../google/cloud/retail/v2alpha/catalog.proto | 477 --- .../retail/v2alpha/catalog_service.proto | 527 --- .../google/cloud/retail/v2alpha/common.proto | 794 ----- .../retail/v2alpha/completion_service.proto | 255 -- .../google/cloud/retail/v2alpha/control.proto | 100 - .../retail/v2alpha/control_service.proto | 185 - .../cloud/retail/v2alpha/export_config.proto | 107 - .../cloud/retail/v2alpha/import_config.proto | 408 --- .../merchant_center_account_link.proto | 137 - ...merchant_center_account_link_service.proto | 140 - .../google/cloud/retail/v2alpha/model.proto | 451 --- .../cloud/retail/v2alpha/model_service.proto | 263 -- .../retail/v2alpha/prediction_service.proto | 226 -- .../google/cloud/retail/v2alpha/product.proto | 598 ---- .../retail/v2alpha/product_service.proto | 988 ------ .../cloud/retail/v2alpha/promotion.proto | 40 - .../cloud/retail/v2alpha/purge_config.proto | 174 - .../cloud/retail/v2alpha/search_service.proto | 1032 ------ .../cloud/retail/v2alpha/serving_config.proto | 281 -- .../v2alpha/serving_config_service.proto | 241 -- .../cloud/retail/v2alpha/user_event.proto | 354 -- .../retail/v2alpha/user_event_service.proto | 210 -- .../catalog_service.add_catalog_attribute.js | 68 - ...service.batch_remove_catalog_attributes.js | 70 - .../catalog_service.get_attributes_config.js | 62 - .../catalog_service.get_completion_config.js | 62 - .../catalog_service.get_default_branch.js | 61 - .../v2alpha/catalog_service.list_catalogs.js | 86 - ...atalog_service.remove_catalog_attribute.js | 68 - ...talog_service.replace_catalog_attribute.js | 76 - .../catalog_service.set_default_branch.js | 84 - ...atalog_service.update_attributes_config.js | 70 - .../v2alpha/catalog_service.update_catalog.js | 73 - ...atalog_service.update_completion_config.js | 78 - .../completion_service.complete_query.js | 137 - ...mpletion_service.import_completion_data.js | 76 - .../v2alpha/control_service.create_control.js | 75 - .../v2alpha/control_service.delete_control.js | 62 - .../v2alpha/control_service.get_control.js | 62 - .../v2alpha/control_service.list_controls.js | 82 - .../v2alpha/control_service.update_control.js | 69 - ...ice.create_merchant_center_account_link.js | 75 - ...ice.delete_merchant_center_account_link.js | 62 - ...vice.list_merchant_center_account_links.js | 63 - .../v2alpha/model_service.create_model.js | 74 - .../v2alpha/model_service.delete_model.js | 63 - .../v2alpha/model_service.get_model.js | 63 - .../v2alpha/model_service.list_models.js | 75 - .../v2alpha/model_service.pause_model.js | 63 - .../v2alpha/model_service.resume_model.js | 63 - .../v2alpha/model_service.tune_model.js | 64 - .../v2alpha/model_service.update_model.js | 67 - .../v2alpha/prediction_service.predict.js | 187 - .../product_service.add_fulfillment_places.js | 119 - .../product_service.add_local_inventories.js | 103 - .../v2alpha/product_service.create_product.js | 83 - .../v2alpha/product_service.delete_product.js | 89 - .../v2alpha/product_service.get_product.js | 68 - .../product_service.import_products.js | 107 - .../v2alpha/product_service.list_products.js | 144 - .../v2alpha/product_service.purge_products.js | 104 - ...oduct_service.remove_fulfillment_places.js | 115 - ...roduct_service.remove_local_inventories.js | 88 - .../v2alpha/product_service.set_inventory.js | 131 - .../v2alpha/product_service.update_product.js | 87 - .../v2alpha/search_service.search.js | 332 -- .../serving_config_service.add_control.js | 68 - ...ng_config_service.create_serving_config.js | 75 - ...ng_config_service.delete_serving_config.js | 62 - ...rving_config_service.get_serving_config.js | 62 - ...ing_config_service.list_serving_configs.js | 75 - .../serving_config_service.remove_control.js | 68 - ...ng_config_service.update_serving_config.js | 69 - ..._metadata.google.cloud.retail.v2alpha.json | 2735 -------------- .../user_event_service.collect_user_event.js | 93 - .../user_event_service.import_user_events.js | 72 - .../user_event_service.purge_user_events.js | 94 - .../user_event_service.rejoin_user_events.js | 70 - .../user_event_service.write_user_event.js | 74 - .../google-cloud-retail/v2alpha/src/index.ts | 43 - .../src/v2alpha/catalog_service_client.ts | 2369 ------------- .../catalog_service_client_config.json | 95 - .../v2alpha/catalog_service_proto_list.json | 24 - .../src/v2alpha/completion_service_client.ts | 1363 ------- .../completion_service_client_config.json | 45 - .../completion_service_proto_list.json | 24 - .../src/v2alpha/control_service_client.ts | 1621 --------- .../control_service_client_config.json | 46 - .../v2alpha/control_service_proto_list.json | 24 - .../v2alpha/src/v2alpha/gapic_metadata.json | 733 ---- .../v2alpha/src/v2alpha/index.ts | 28 - ...hant_center_account_link_service_client.ts | 1357 ------- ...er_account_link_service_client_config.json | 38 - ...enter_account_link_service_proto_list.json | 24 - .../src/v2alpha/model_service_client.ts | 1877 ---------- .../v2alpha/model_service_client_config.json | 66 - .../src/v2alpha/model_service_proto_list.json | 24 - .../src/v2alpha/prediction_service_client.ts | 1291 ------- .../prediction_service_client_config.json | 40 - .../prediction_service_proto_list.json | 24 - .../src/v2alpha/product_service_client.ts | 3133 ----------------- .../product_service_client_config.json | 104 - .../v2alpha/product_service_proto_list.json | 24 - .../src/v2alpha/search_service_client.ts | 2165 ------------ .../v2alpha/search_service_client_config.json | 40 - .../v2alpha/search_service_proto_list.json | 24 - .../v2alpha/serving_config_service_client.ts | 1759 --------- .../serving_config_service_client_config.json | 54 - .../serving_config_service_proto_list.json | 24 - .../src/v2alpha/user_event_service_client.ts | 1625 --------- .../user_event_service_client_config.json | 78 - .../user_event_service_proto_list.json | 24 - .../system-test/fixtures/sample/src/index.js | 36 - .../system-test/fixtures/sample/src/index.ts | 86 - .../v2alpha/system-test/install.ts | 49 - .../test/gapic_catalog_service_v2alpha.ts | 2574 -------------- .../test/gapic_completion_service_v2alpha.ts | 1288 ------- .../test/gapic_control_service_v2alpha.ts | 1718 --------- ...ant_center_account_link_service_v2alpha.ts | 1396 -------- .../test/gapic_model_service_v2alpha.ts | 2150 ----------- .../test/gapic_prediction_service_v2alpha.ts | 1118 ------ .../test/gapic_product_service_v2alpha.ts | 2870 --------------- .../test/gapic_search_service_v2alpha.ts | 1390 -------- .../gapic_serving_config_service_v2alpha.ts | 1934 ---------- .../test/gapic_user_event_service_v2alpha.ts | 1704 --------- .../google-cloud-retail/v2alpha/tsconfig.json | 19 - .../v2alpha/webpack.config.js | 64 - .../google-cloud-retail/v2beta/.eslintignore | 7 - .../google-cloud-retail/v2beta/.eslintrc.json | 3 - .../google-cloud-retail/v2beta/.gitignore | 14 - .../google-cloud-retail/v2beta/.jsdoc.js | 55 - .../google-cloud-retail/v2beta/.mocharc.js | 33 - .../google-cloud-retail/v2beta/.prettierrc.js | 22 - .../google-cloud-retail/v2beta/README.md | 1 - .../v2beta/linkinator.config.json | 16 - .../google-cloud-retail/v2beta/package.json | 72 - .../google/cloud/retail/v2beta/catalog.proto | 476 --- .../cloud/retail/v2beta/catalog_service.proto | 527 --- .../google/cloud/retail/v2beta/common.proto | 793 ----- .../retail/v2beta/completion_service.proto | 220 -- .../google/cloud/retail/v2beta/control.proto | 100 - .../cloud/retail/v2beta/control_service.proto | 185 - .../cloud/retail/v2beta/export_config.proto | 107 - .../cloud/retail/v2beta/import_config.proto | 386 -- .../google/cloud/retail/v2beta/model.proto | 239 -- .../cloud/retail/v2beta/model_service.proto | 263 -- .../retail/v2beta/prediction_service.proto | 226 -- .../google/cloud/retail/v2beta/product.proto | 597 ---- .../cloud/retail/v2beta/product_service.proto | 925 ----- .../cloud/retail/v2beta/promotion.proto | 40 - .../cloud/retail/v2beta/purge_config.proto | 83 - .../cloud/retail/v2beta/search_service.proto | 990 ------ .../cloud/retail/v2beta/serving_config.proto | 281 -- .../v2beta/serving_config_service.proto | 240 -- .../cloud/retail/v2beta/user_event.proto | 352 -- .../retail/v2beta/user_event_service.proto | 210 -- .../catalog_service.add_catalog_attribute.js | 68 - ...service.batch_remove_catalog_attributes.js | 70 - .../catalog_service.get_attributes_config.js | 62 - .../catalog_service.get_completion_config.js | 62 - .../catalog_service.get_default_branch.js | 61 - .../v2beta/catalog_service.list_catalogs.js | 86 - ...atalog_service.remove_catalog_attribute.js | 68 - ...talog_service.replace_catalog_attribute.js | 76 - .../catalog_service.set_default_branch.js | 84 - ...atalog_service.update_attributes_config.js | 70 - .../v2beta/catalog_service.update_catalog.js | 73 - ...atalog_service.update_completion_config.js | 78 - .../completion_service.complete_query.js | 132 - ...mpletion_service.import_completion_data.js | 76 - .../v2beta/control_service.create_control.js | 75 - .../v2beta/control_service.delete_control.js | 62 - .../v2beta/control_service.get_control.js | 62 - .../v2beta/control_service.list_controls.js | 82 - .../v2beta/control_service.update_control.js | 69 - .../v2beta/model_service.create_model.js | 74 - .../v2beta/model_service.delete_model.js | 63 - .../v2beta/model_service.get_model.js | 63 - .../v2beta/model_service.list_models.js | 75 - .../v2beta/model_service.pause_model.js | 63 - .../v2beta/model_service.resume_model.js | 63 - .../v2beta/model_service.tune_model.js | 64 - .../v2beta/model_service.update_model.js | 67 - .../v2beta/prediction_service.predict.js | 187 - .../product_service.add_fulfillment_places.js | 119 - .../product_service.add_local_inventories.js | 103 - .../v2beta/product_service.create_product.js | 83 - .../v2beta/product_service.delete_product.js | 78 - .../v2beta/product_service.get_product.js | 68 - .../v2beta/product_service.import_products.js | 98 - .../v2beta/product_service.list_products.js | 135 - ...oduct_service.remove_fulfillment_places.js | 115 - ...roduct_service.remove_local_inventories.js | 88 - .../v2beta/product_service.set_inventory.js | 131 - .../v2beta/product_service.update_product.js | 87 - .../generated/v2beta/search_service.search.js | 312 -- .../serving_config_service.add_control.js | 68 - ...ng_config_service.create_serving_config.js | 75 - ...ng_config_service.delete_serving_config.js | 62 - ...rving_config_service.get_serving_config.js | 62 - ...ing_config_service.list_serving_configs.js | 75 - .../serving_config_service.remove_control.js | 68 - ...ng_config_service.update_serving_config.js | 69 - ...t_metadata.google.cloud.retail.v2beta.json | 2543 ------------- .../user_event_service.collect_user_event.js | 93 - .../user_event_service.import_user_events.js | 72 - .../user_event_service.purge_user_events.js | 94 - .../user_event_service.rejoin_user_events.js | 70 - .../user_event_service.write_user_event.js | 74 - .../google-cloud-retail/v2beta/src/index.ts | 41 - .../src/v2beta/catalog_service_client.ts | 2304 ------------ .../v2beta/catalog_service_client_config.json | 95 - .../v2beta/catalog_service_proto_list.json | 22 - .../src/v2beta/completion_service_client.ts | 1294 ------- .../completion_service_client_config.json | 45 - .../v2beta/completion_service_proto_list.json | 22 - .../src/v2beta/control_service_client.ts | 1556 -------- .../v2beta/control_service_client_config.json | 46 - .../v2beta/control_service_proto_list.json | 22 - .../v2beta/src/v2beta/gapic_metadata.json | 679 ---- .../v2beta/src/v2beta/index.ts | 27 - .../v2beta/src/v2beta/model_service_client.ts | 1812 ---------- .../v2beta/model_service_client_config.json | 58 - .../src/v2beta/model_service_proto_list.json | 22 - .../src/v2beta/prediction_service_client.ts | 1226 ------- .../prediction_service_client_config.json | 40 - .../v2beta/prediction_service_proto_list.json | 22 - .../src/v2beta/product_service_client.ts | 2865 --------------- .../v2beta/product_service_client_config.json | 99 - .../v2beta/product_service_proto_list.json | 22 - .../src/v2beta/search_service_client.ts | 2043 ----------- .../v2beta/search_service_client_config.json | 40 - .../src/v2beta/search_service_proto_list.json | 22 - .../v2beta/serving_config_service_client.ts | 1693 --------- .../serving_config_service_client_config.json | 54 - .../serving_config_service_proto_list.json | 22 - .../src/v2beta/user_event_service_client.ts | 1560 -------- .../user_event_service_client_config.json | 78 - .../v2beta/user_event_service_proto_list.json | 22 - .../system-test/fixtures/sample/src/index.js | 35 - .../system-test/fixtures/sample/src/index.ts | 80 - .../v2beta/system-test/install.ts | 49 - .../test/gapic_catalog_service_v2beta.ts | 2520 ------------- .../test/gapic_completion_service_v2beta.ts | 1234 ------- .../test/gapic_control_service_v2beta.ts | 1664 --------- .../v2beta/test/gapic_model_service_v2beta.ts | 2096 ----------- .../test/gapic_prediction_service_v2beta.ts | 1064 ------ .../test/gapic_product_service_v2beta.ts | 2662 -------------- .../test/gapic_search_service_v2beta.ts | 1336 ------- .../gapic_serving_config_service_v2beta.ts | 1880 ---------- .../test/gapic_user_event_service_v2beta.ts | 1650 --------- .../google-cloud-retail/v2beta/tsconfig.json | 19 - .../v2beta/webpack.config.js | 64 - ...merchant_center_account_link_service.proto | 12 +- .../google-cloud-retail/protos/protos.json | 4 +- ...ippet_metadata.google.cloud.retail.v2.json | 2 +- ..._metadata.google.cloud.retail.v2alpha.json | 6 +- ...t_metadata.google.cloud.retail.v2beta.json | 2 +- ...hant_center_account_link_service_client.ts | 13 +- ...ant_center_account_link_service_v2alpha.ts | 28 +- 393 files changed, 29 insertions(+), 151040 deletions(-) delete mode 100644 owl-bot-staging/google-cloud-retail/v2/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-retail/v2/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2/.gitignore delete mode 100644 owl-bot-staging/google-cloud-retail/v2/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/README.md delete mode 100644 owl-bot-staging/google-cloud-retail/v2/linkinator.config.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2/package.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/catalog.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/catalog_service.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/common.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/completion_service.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/control.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/control_service.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/import_config.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/model.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/model_service.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/prediction_service.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/product.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/product_service.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/promotion.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/purge_config.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/search_service.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/serving_config.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/serving_config_service.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/user_event.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/user_event_service.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.add_catalog_attribute.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.get_attributes_config.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.get_completion_config.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.get_default_branch.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.list_catalogs.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.remove_catalog_attribute.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.replace_catalog_attribute.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.set_default_branch.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.update_attributes_config.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.update_catalog.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.update_completion_config.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/completion_service.complete_query.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/completion_service.import_completion_data.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/control_service.create_control.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/control_service.delete_control.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/control_service.get_control.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/control_service.list_controls.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/control_service.update_control.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.create_model.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.delete_model.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.get_model.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.list_models.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.pause_model.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.resume_model.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.tune_model.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.update_model.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/prediction_service.predict.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.add_fulfillment_places.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.add_local_inventories.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.create_product.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.delete_product.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.get_product.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.import_products.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.list_products.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.remove_fulfillment_places.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.remove_local_inventories.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.set_inventory.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.update_product.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/search_service.search.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/serving_config_service.add_control.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/serving_config_service.create_serving_config.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/serving_config_service.delete_serving_config.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/serving_config_service.get_serving_config.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/serving_config_service.list_serving_configs.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/serving_config_service.remove_control.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/serving_config_service.update_serving_config.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/snippet_metadata.google.cloud.retail.v2.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/user_event_service.collect_user_event.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/user_event_service.import_user_events.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/user_event_service.purge_user_events.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/user_event_service.rejoin_user_events.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/user_event_service.write_user_event.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/catalog_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/catalog_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/catalog_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/completion_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/completion_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/completion_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/control_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/control_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/control_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/index.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/model_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/model_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/model_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/prediction_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/prediction_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/prediction_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/product_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/product_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/product_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/search_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/search_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/search_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/serving_config_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/serving_config_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/serving_config_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/user_event_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/user_event_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2/src/v2/user_event_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2/test/gapic_catalog_service_v2.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2/test/gapic_completion_service_v2.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2/test/gapic_control_service_v2.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2/test/gapic_model_service_v2.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2/test/gapic_prediction_service_v2.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2/test/gapic_product_service_v2.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2/test/gapic_search_service_v2.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2/test/gapic_serving_config_service_v2.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2/test/gapic_user_event_service_v2.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2/webpack.config.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/.gitignore delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/README.md delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/linkinator.config.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/package.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/catalog.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/catalog_service.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/common.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/completion_service.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/control.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/control_service.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/export_config.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/import_config.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/merchant_center_account_link.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/merchant_center_account_link_service.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/model.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/model_service.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/prediction_service.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/product.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/product_service.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/promotion.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/purge_config.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/search_service.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/serving_config.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/serving_config_service.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/user_event.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/user_event_service.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.add_catalog_attribute.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.batch_remove_catalog_attributes.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.get_attributes_config.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.get_completion_config.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.get_default_branch.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.list_catalogs.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.remove_catalog_attribute.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.replace_catalog_attribute.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.set_default_branch.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.update_attributes_config.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.update_catalog.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.update_completion_config.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/completion_service.complete_query.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/completion_service.import_completion_data.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/control_service.create_control.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/control_service.delete_control.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/control_service.get_control.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/control_service.list_controls.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/control_service.update_control.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/merchant_center_account_link_service.create_merchant_center_account_link.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/merchant_center_account_link_service.delete_merchant_center_account_link.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/merchant_center_account_link_service.list_merchant_center_account_links.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.create_model.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.delete_model.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.get_model.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.list_models.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.pause_model.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.resume_model.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.tune_model.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.update_model.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/prediction_service.predict.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.add_fulfillment_places.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.add_local_inventories.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.create_product.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.delete_product.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.get_product.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.import_products.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.list_products.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.purge_products.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.remove_fulfillment_places.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.remove_local_inventories.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.set_inventory.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.update_product.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/search_service.search.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.add_control.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.create_serving_config.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.delete_serving_config.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.get_serving_config.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.list_serving_configs.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.remove_control.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.update_serving_config.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/snippet_metadata.google.cloud.retail.v2alpha.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/user_event_service.collect_user_event.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/user_event_service.import_user_events.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/user_event_service.purge_user_events.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/user_event_service.rejoin_user_events.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/user_event_service.write_user_event.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/catalog_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/catalog_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/catalog_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/completion_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/completion_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/completion_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/control_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/control_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/control_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/index.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/merchant_center_account_link_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/merchant_center_account_link_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/merchant_center_account_link_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/model_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/model_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/model_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/prediction_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/prediction_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/prediction_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/product_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/product_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/product_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/search_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/search_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/search_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/serving_config_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/serving_config_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/serving_config_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/user_event_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/user_event_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/user_event_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_catalog_service_v2alpha.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_completion_service_v2alpha.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_control_service_v2alpha.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_merchant_center_account_link_service_v2alpha.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_model_service_v2alpha.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_prediction_service_v2alpha.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_product_service_v2alpha.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_search_service_v2alpha.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_serving_config_service_v2alpha.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_user_event_service_v2alpha.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2alpha/webpack.config.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/.eslintignore delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/.eslintrc.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/.gitignore delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/.jsdoc.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/.mocharc.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/.prettierrc.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/README.md delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/linkinator.config.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/package.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/catalog.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/catalog_service.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/common.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/completion_service.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/control.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/control_service.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/export_config.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/import_config.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/model.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/model_service.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/prediction_service.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/product.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/product_service.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/promotion.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/purge_config.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/search_service.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/serving_config.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/serving_config_service.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/user_event.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/user_event_service.proto delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.add_catalog_attribute.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.batch_remove_catalog_attributes.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.get_attributes_config.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.get_completion_config.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.get_default_branch.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.list_catalogs.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.remove_catalog_attribute.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.replace_catalog_attribute.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.set_default_branch.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.update_attributes_config.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.update_catalog.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.update_completion_config.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/completion_service.complete_query.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/completion_service.import_completion_data.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/control_service.create_control.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/control_service.delete_control.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/control_service.get_control.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/control_service.list_controls.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/control_service.update_control.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.create_model.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.delete_model.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.get_model.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.list_models.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.pause_model.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.resume_model.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.tune_model.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.update_model.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/prediction_service.predict.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.add_fulfillment_places.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.add_local_inventories.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.create_product.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.delete_product.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.get_product.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.import_products.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.list_products.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.remove_fulfillment_places.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.remove_local_inventories.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.set_inventory.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.update_product.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/search_service.search.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.add_control.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.create_serving_config.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.delete_serving_config.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.get_serving_config.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.list_serving_configs.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.remove_control.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.update_serving_config.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/snippet_metadata.google.cloud.retail.v2beta.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/user_event_service.collect_user_event.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/user_event_service.import_user_events.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/user_event_service.purge_user_events.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/user_event_service.rejoin_user_events.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/user_event_service.write_user_event.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/catalog_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/catalog_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/catalog_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/completion_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/completion_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/completion_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/control_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/control_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/control_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/index.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/model_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/model_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/model_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/prediction_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/prediction_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/prediction_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/product_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/product_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/product_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/search_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/search_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/search_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/serving_config_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/serving_config_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/serving_config_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/user_event_service_client.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/user_event_service_client_config.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/user_event_service_proto_list.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/system-test/install.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/test/gapic_catalog_service_v2beta.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/test/gapic_completion_service_v2beta.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/test/gapic_control_service_v2beta.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/test/gapic_model_service_v2beta.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/test/gapic_prediction_service_v2beta.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/test/gapic_product_service_v2beta.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/test/gapic_search_service_v2beta.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/test/gapic_serving_config_service_v2beta.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/test/gapic_user_event_service_v2beta.ts delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/tsconfig.json delete mode 100644 owl-bot-staging/google-cloud-retail/v2beta/webpack.config.js diff --git a/owl-bot-staging/google-cloud-retail/v2/.eslintignore b/owl-bot-staging/google-cloud-retail/v2/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/google-cloud-retail/v2/.eslintrc.json b/owl-bot-staging/google-cloud-retail/v2/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-retail/v2/.gitignore b/owl-bot-staging/google-cloud-retail/v2/.gitignore deleted file mode 100644 index d4f03a0df2e..00000000000 --- a/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2/.jsdoc.js b/owl-bot-staging/google-cloud-retail/v2/.jsdoc.js deleted file mode 100644 index 66e9db869e8..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/.jsdoc.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file 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 2023 Google LLC', - includeDate: false, - sourceFiles: false, - systemName: '@google-cloud/retail', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-retail/v2/.mocharc.js b/owl-bot-staging/google-cloud-retail/v2/.mocharc.js deleted file mode 100644 index 1a38f257db7..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/.mocharc.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -const config = { - "enable-source-maps": true, - "throw-deprecation": true, - "timeout": 10000 -} -if (process.env.MOCHA_THROW_DEPRECATION === 'false') { - delete config['throw-deprecation']; -} -if (process.env.MOCHA_REPORTER) { - config.reporter = process.env.MOCHA_REPORTER; -} -if (process.env.MOCHA_REPORTER_OUTPUT) { - config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; -} -module.exports = config diff --git a/owl-bot-staging/google-cloud-retail/v2/.prettierrc.js b/owl-bot-staging/google-cloud-retail/v2/.prettierrc.js deleted file mode 100644 index 55639e70f9e..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/.prettierrc.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -module.exports = { - ...require('gts/.prettierrc.json') -} diff --git a/owl-bot-staging/google-cloud-retail/v2/README.md b/owl-bot-staging/google-cloud-retail/v2/README.md deleted file mode 100644 index 822c4573817..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/README.md +++ /dev/null @@ -1 +0,0 @@ -Retail: Nodejs Client diff --git a/owl-bot-staging/google-cloud-retail/v2/linkinator.config.json b/owl-bot-staging/google-cloud-retail/v2/linkinator.config.json deleted file mode 100644 index befd23c8633..00000000000 --- a/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2/package.json b/owl-bot-staging/google-cloud-retail/v2/package.json deleted file mode 100644 index 468da5696b6..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/package.json +++ /dev/null @@ -1,72 +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", - "model service", - "prediction service", - "product service", - "search service", - "serving config service", - "user event service" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^3.5.7" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.1", - "jsdoc": "^4.0.0", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.1", - "linkinator": "^4.1.2", - "mocha": "^10.2.0", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.0.1", - "ts-loader": "^8.4.0", - "typescript": "^4.8.4", - "webpack": "^4.46.0", - "webpack-cli": "^4.10.0" - }, - "engines": { - "node": ">=v12" - } -} diff --git a/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/catalog.proto b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/catalog.proto deleted file mode 100644 index 4205e00147e..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/catalog.proto +++ /dev/null @@ -1,393 +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/import_config.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2"; -option go_package = "cloud.google.com/go/retail/apiv2/retailpb;retailpb"; -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; -} - -// 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.v2.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. - 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. - 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. - SEARCHABLE_OPTION_UNSPECIFIED = 0; - - // Searchable option enabled for an attribute. - SEARCHABLE_ENABLED = 1; - - // Searchable option disabled for an attribute. - SEARCHABLE_DISABLED = 2; - } - - // The status of the exact-searchable option of a catalog attribute. - enum ExactSearchableOption { - // Value used when unset. - EXACT_SEARCHABLE_OPTION_UNSPECIFIED = 0; - - // Exact searchable option enabled for an attribute. - EXACT_SEARCHABLE_ENABLED = 1; - - // Exact searchable option disabled for an attribute. - EXACT_SEARCHABLE_DISABLED = 2; - } - - // The status of the retrievable option of a catalog attribute. - enum RetrievableOption { - // Value used when unset. - RETRIEVABLE_OPTION_UNSPECIFIED = 0; - - // Retrievable option enabled for an attribute. - RETRIEVABLE_ENABLED = 1; - - // Retrievable option disabled for an attribute. - RETRIEVABLE_DISABLED = 2; - } - - // Required. Attribute name. - // For example: `color`, `brands`, `attributes.custom_attribute`, such as - // `attributes.xyz`. - // To be indexable, the attribute name can contain only alpha-numeric - // characters and underscores. For example, an attribute named - // `attributes.abc_xyz` can be indexed, but an attribute named - // `attributes.abc-xyz` cannot be indexed. - // - // If the attribute key starts with `attributes.`, then the attribute is a - // custom attribute. Attributes such as `brands`, `patterns`, and `title` are - // built-in and called system attributes. - 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.v2.Product] - // is using this attribute in - // [Product.attributes][google.cloud.retail.v2.Product.attributes]. Otherwise, - // this field is `False`. - // - // [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] can be - // pre-loaded by using - // [CatalogService.AddCatalogAttribute][google.cloud.retail.v2.CatalogService.AddCatalogAttribute], - // [CatalogService.ImportCatalogAttributes][], or - // [CatalogService.UpdateAttributesConfig][google.cloud.retail.v2.CatalogService.UpdateAttributesConfig] - // APIs. This field is `False` for pre-loaded - // [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute]s. - // - // Only pre-loaded [catalog - // attributes][google.cloud.retail.v2.CatalogAttribute] that are neither in - // use by products nor predefined can be deleted. [Catalog - // attributes][google.cloud.retail.v2.CatalogAttribute] that are - // either in use by products or are predefined attributes 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.v2.Product.attributes]. - AttributeType type = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // When - // [AttributesConfig.attribute_config_level][google.cloud.retail.v2.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.v2.SearchService.Search]. - // - // Must be specified, otherwise throws INVALID_FORMAT error. - 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.v2.CatalogAttribute.indexable_option] - // is INDEXABLE_DISABLED. Otherwise, an INVALID_ARGUMENT error is returned. - // - // Must be specified, otherwise throws INVALID_FORMAT error. - DynamicFacetableOption dynamic_facetable_option = 6; - - // When - // [AttributesConfig.attribute_config_level][google.cloud.retail.v2.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.v2.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.v2.SearchService.Search], as - // there are no text values associated to numerical attributes. - // - // Must be specified, otherwise throws INVALID_FORMAT error. - SearchableOption searchable_option = 7; - - // If EXACT_SEARCHABLE_ENABLED, attribute values will be exact searchable. - // This property only applies to textual custom attributes and requires - // indexable set to enabled to enable exact-searchable. If unset, the server - // behavior defaults to - // [EXACT_SEARCHABLE_DISABLED][google.cloud.retail.v2.CatalogAttribute.ExactSearchableOption.EXACT_SEARCHABLE_DISABLED]. - ExactSearchableOption exact_searchable_option = 11; - - // If RETRIEVABLE_ENABLED, attribute values are retrievable in the search - // results. If unset, the server behavior defaults to - // [RETRIEVABLE_DISABLED][google.cloud.retail.v2.CatalogAttribute.RetrievableOption.RETRIEVABLE_DISABLED]. - RetrievableOption retrievable_option = 12; -} - -// 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.v2.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. Default - // value is 20. If left unset or set to 0, then will fallback to default - // value. - // - // Value range is 1 to 20. - 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. - // - // Value range is 1 to 20. - 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.v2.CompleteQueryRequest]. - bool auto_learning = 11; - - // Output only. The source data for the latest import of the autocomplete - // suggestion phrases. - 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 source data for the latest import of the autocomplete - // denylist phrases. - CompletionDataInputConfig denylist_input_config = 7 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Name of the 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 source data for the latest import of the autocomplete - // allowlist phrases. - CompletionDataInputConfig allowlist_input_config = 9 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Name of the 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]; -} - -// 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/google-cloud-retail/v2/protos/google/cloud/retail/v2/catalog_service.proto b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/catalog_service.proto deleted file mode 100644 index 14b45841baa..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/catalog_service.proto +++ /dev/null @@ -1,476 +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 = "cloud.google.com/go/retail/apiv2/retailpb;retailpb"; -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"; - } - - // Gets a [CompletionConfig][google.cloud.retail.v2.CompletionConfig]. - rpc GetCompletionConfig(GetCompletionConfigRequest) - returns (CompletionConfig) { - option (google.api.http) = { - get: "/v2/{name=projects/*/locations/*/catalogs/*/completionConfig}" - }; - option (google.api.method_signature) = "name"; - } - - // Updates the [CompletionConfig][google.cloud.retail.v2.CompletionConfig]s. - rpc UpdateCompletionConfig(UpdateCompletionConfigRequest) - returns (CompletionConfig) { - option (google.api.http) = { - patch: "/v2/{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.v2.AttributesConfig]. - rpc GetAttributesConfig(GetAttributesConfigRequest) - returns (AttributesConfig) { - option (google.api.http) = { - get: "/v2/{name=projects/*/locations/*/catalogs/*/attributesConfig}" - }; - option (google.api.method_signature) = "name"; - } - - // Updates the [AttributesConfig][google.cloud.retail.v2.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: "/v2/{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.v2.CatalogAttribute] to the - // [AttributesConfig][google.cloud.retail.v2.AttributesConfig]. - // - // If the [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] to add - // already exists, an ALREADY_EXISTS error is returned. - rpc AddCatalogAttribute(AddCatalogAttributeRequest) - returns (AttributesConfig) { - option (google.api.http) = { - post: "/v2/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:addCatalogAttribute" - body: "*" - }; - } - - // Removes the specified - // [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] from the - // [AttributesConfig][google.cloud.retail.v2.AttributesConfig]. - // - // If the [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] to - // remove does not exist, a NOT_FOUND error is returned. - rpc RemoveCatalogAttribute(RemoveCatalogAttributeRequest) - returns (AttributesConfig) { - option (google.api.http) = { - post: "/v2/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:removeCatalogAttribute" - body: "*" - }; - } - - // Replaces the specified - // [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] in the - // [AttributesConfig][google.cloud.retail.v2.AttributesConfig] by updating the - // catalog attribute with the same - // [CatalogAttribute.key][google.cloud.retail.v2.CatalogAttribute.key]. - // - // If the [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] to - // replace does not exist, a NOT_FOUND error is returned. - rpc ReplaceCatalogAttribute(ReplaceCatalogAttributeRequest) - returns (AttributesConfig) { - option (google.api.http) = { - post: "/v2/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:replaceCatalogAttribute" - body: "*" - }; - } -} - -// 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; -} - -// Request for -// [CatalogService.GetCompletionConfig][google.cloud.retail.v2.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.v2.CatalogService.UpdateCompletionConfig] -// method. -message UpdateCompletionConfigRequest { - // Required. The [CompletionConfig][google.cloud.retail.v2.CompletionConfig] - // to update. - // - // If the caller does not have permission to update the - // [CompletionConfig][google.cloud.retail.v2.CompletionConfig], then a - // PERMISSION_DENIED error is returned. - // - // If the [CompletionConfig][google.cloud.retail.v2.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.v2.CompletionConfig] to update. The - // following are the only supported fields: - // - // * [CompletionConfig.matching_order][google.cloud.retail.v2.CompletionConfig.matching_order] - // * [CompletionConfig.max_suggestions][google.cloud.retail.v2.CompletionConfig.max_suggestions] - // * [CompletionConfig.min_prefix_length][google.cloud.retail.v2.CompletionConfig.min_prefix_length] - // * [CompletionConfig.auto_learning][google.cloud.retail.v2.CompletionConfig.auto_learning] - // - // If not set, all supported fields are updated. - google.protobuf.FieldMask update_mask = 2; -} - -// Request for -// [CatalogService.GetAttributesConfig][google.cloud.retail.v2.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.v2.CatalogService.UpdateAttributesConfig] -// method. -message UpdateAttributesConfigRequest { - // Required. The [AttributesConfig][google.cloud.retail.v2.AttributesConfig] - // to update. - AttributesConfig attributes_config = 1 - [(google.api.field_behavior) = REQUIRED]; - - // Indicates which fields in the provided - // [AttributesConfig][google.cloud.retail.v2.AttributesConfig] to update. The - // following is the only supported field: - // - // * [AttributesConfig.catalog_attributes][google.cloud.retail.v2.AttributesConfig.catalog_attributes] - // - // If not set, all supported fields are updated. - google.protobuf.FieldMask update_mask = 2; -} - -// Request for -// [CatalogService.AddCatalogAttribute][google.cloud.retail.v2.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.v2.CatalogAttribute] - // to add. - CatalogAttribute catalog_attribute = 2 - [(google.api.field_behavior) = REQUIRED]; -} - -// Request for -// [CatalogService.RemoveCatalogAttribute][google.cloud.retail.v2.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.v2.CatalogAttribute] to remove. - string key = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for -// [CatalogService.ReplaceCatalogAttribute][google.cloud.retail.v2.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.v2.CatalogAttribute]. - CatalogAttribute catalog_attribute = 2 - [(google.api.field_behavior) = REQUIRED]; - - // Indicates which fields in the provided - // [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] to update. The - // following are NOT supported: - // - // * [CatalogAttribute.key][google.cloud.retail.v2.CatalogAttribute.key] - // - // If not set, all supported fields are updated. - google.protobuf.FieldMask update_mask = 3; -} diff --git a/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/common.proto b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/common.proto deleted file mode 100644 index d04afc3d178..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/common.proto +++ /dev/null @@ -1,782 +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 = "cloud.google.com/go/retail/apiv2/retailpb;retailpb"; -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"; - -// At which level we offer configuration for attributes. -enum AttributeConfigLevel { - // Value used when unset. In this case, server behavior defaults to - // [CATALOG_LEVEL_ATTRIBUTE_CONFIG][google.cloud.retail.v2.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.v2.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; -} - -// If filtering for recommendations is enabled. -enum RecommendationsFilteringOption { - // Value used when unset. - // In this case, server behavior defaults to - // [RECOMMENDATIONS_FILTERING_DISABLED][google.cloud.retail.v2.RecommendationsFilteringOption.RECOMMENDATIONS_FILTERING_DISABLED]. - RECOMMENDATIONS_FILTERING_OPTION_UNSPECIFIED = 0; - - // Recommendation filtering is disabled. - RECOMMENDATIONS_FILTERING_DISABLED = 1; - - // Recommendation filtering is enabled. - RECOMMENDATIONS_FILTERING_ENABLED = 3; -} - -// The use case of Cloud Retail Search. -enum SearchSolutionUseCase { - // The value when it's unspecified. In this case, server behavior defaults to - // [SEARCH_SOLUTION_USE_CASE_SEARCH][google.cloud.retail.v2.SearchSolutionUseCase.SEARCH_SOLUTION_USE_CASE_SEARCH]. - SEARCH_SOLUTION_USE_CASE_UNSPECIFIED = 0; - - // Search use case. Expects the traffic has a non-empty - // [query][google.cloud.retail.v2.SearchRequest.query]. - SEARCH_SOLUTION_USE_CASE_SEARCH = 1; - - // Browse use case. Expects the traffic has an empty - // [query][google.cloud.retail.v2.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. - // For example, "a b c" is 3 terms and allowed, but " a b c d" is 4 terms - // and not allowed for a 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 rules only work for [controls][google.cloud.retail.v2.Control] with -// [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2.SolutionType.SOLUTION_TYPE_SEARCH]. -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.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 products_filter = 2; - } - - // * Rule Condition: - // - No - // [Condition.query_terms][google.cloud.retail.v2.Condition.query_terms] - // provided is a global match. - // - 1 or more - // [Condition.query_terms][google.cloud.retail.v2.Condition.query_terms] - // provided are combined with OR operator. - // * Action Input: The request query and filter that are 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.v2.Rule.FilterAction.filter] must be set. - // * Filter syntax is identical to - // [SearchRequest.filter][google.cloud.retail.v2.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][google.cloud.retail.v2.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.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 75 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][google.cloud.retail.v2.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][google.cloud.retail.v2.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 not be larger than 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. - // 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/google-cloud-retail/v2/protos/google/cloud/retail/v2/completion_service.proto b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/completion_service.proto deleted file mode 100644 index 75c2d93710e..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/completion_service.proto +++ /dev/null @@ -1,220 +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 = "cloud.google.com/go/retail/apiv2/retailpb;retailpb"; -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"; - -// Autocomplete service for retail. -// -// This feature is only available for users who have Retail Search enabled. -// 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. - // 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. - // 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" - }; - } -} - -// Autocomplete 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; - - // Note that this field applies for `user-data` dataset only. For requests - // with `cloud-retail` dataset, setting this field has no effect. - // - // 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. We recommend that you - // leave this field empty. - // - // It can 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][google.cloud.retail.v2.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; - - // The entity for customers that may run multiple different entities, domains, - // sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, - // `google.com`, `youtube.com`, etc. - // If this is set, it should be exactly matched with - // [UserEvent.entity][google.cloud.retail.v2.UserEvent.entity] to get - // per-entity autocomplete results. - string entity = 10; -} - -// Response of the autocomplete 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. It requires - // [UserEvent.product_details][google.cloud.retail.v2.UserEvent.product_details] - // is imported properly. - 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 case. - // - // * 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/google-cloud-retail/v2/protos/google/cloud/retail/v2/control.proto b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/control.proto deleted file mode 100644 index c2b1d1c9d79..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/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.v2; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/retail/v2/common.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2"; -option go_package = "cloud.google.com/go/retail/apiv2/retailpb;retailpb"; -option java_multiple_files = true; -option java_outer_classname = "ControlProto"; -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 dynamic metadata that can be linked to a -// [ServingConfig][google.cloud.retail.v2.ServingConfig] and affect search or -// recommendation results at serving time. -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 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 config][google.cloud.retail.v2.ServingConfig] - // ids that are associated with this control in the same - // [Catalog][google.cloud.retail.v2.Catalog]. - // - // Note the association is managed via the - // [ServingConfig][google.cloud.retail.v2.ServingConfig], this is an output - // only denormalized view. - repeated string associated_serving_config_ids = 5 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Required. Immutable. The solution types that the control 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][google.cloud.retail.v2.SolutionType.SOLUTION_TYPE_SEARCH]. - repeated SolutionType solution_types = 6 [ - (google.api.field_behavior) = REQUIRED, - (google.api.field_behavior) = IMMUTABLE - ]; - - // 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][google.cloud.retail.v2.SearchSolutionUseCase.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; -} diff --git a/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/control_service.proto b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/control_service.proto deleted file mode 100644 index e84e30b2167..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/control_service.proto +++ /dev/null @@ -1,185 +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/control.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2"; -option go_package = "cloud.google.com/go/retail/apiv2/retailpb;retailpb"; -option java_multiple_files = true; -option java_outer_classname = "ControlServiceProto"; -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 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.v2.Control] to create already exists, - // an ALREADY_EXISTS error is returned. - rpc CreateControl(CreateControlRequest) returns (Control) { - option (google.api.http) = { - post: "/v2/{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.v2.Control] to delete does not exist, - // a NOT_FOUND error is returned. - rpc DeleteControl(DeleteControlRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v2/{name=projects/*/locations/*/catalogs/*/controls/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Updates a Control. - // - // [Control][google.cloud.retail.v2.Control] cannot be set to a different - // oneof field, if so an INVALID_ARGUMENT is returned. If the - // [Control][google.cloud.retail.v2.Control] to update does not exist, a - // NOT_FOUND error is returned. - rpc UpdateControl(UpdateControlRequest) returns (Control) { - option (google.api.http) = { - patch: "/v2/{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: "/v2/{name=projects/*/locations/*/catalogs/*/controls/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists all Controls by their parent - // [Catalog][google.cloud.retail.v2.Catalog]. - rpc ListControls(ListControlsRequest) returns (ListControlsResponse) { - option (google.api.http) = { - get: "/v2/{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.v2.Control] to update. The following are NOT - // supported: - // - // * [Control.name][google.cloud.retail.v2.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 get. 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.v2.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/google-cloud-retail/v2/protos/google/cloud/retail/v2/import_config.proto b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/import_config.proto deleted file mode 100644 index f6ff762a37b..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/import_config.proto +++ /dev/null @@ -1,386 +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 = "cloud.google.com/go/retail/apiv2/retailpb;retailpb"; -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. -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][google.cloud.retail.v2.Control] - // per line. - // - // Supported values for catalog attribute imports: - // - // * `catalog_attribute` (default): One CSV - // [CatalogAttribute][google.cloud.retail.v2.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 in - // [ImportProductsRequest][google.cloud.retail.v2.ImportProductsRequest]. - 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`: - // The schema is available here: - // https://support.google.com/analytics/answer/7029846. - // - // Supported values for autocomplete 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 are 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. - 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, all fields are updated. - 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 is sent to - // specified Pub/Sub topic. The message data is 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 `service-@gcp-sa-retail.iam.gserviceaccount.com` has the - // `pubsub.topics.publish` IAM permission on the topic. - 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 is sent to - // specified Pub/Sub topic. The message data is 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 is -// 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 is sent to - // specified Pub/Sub topic. The message data is 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/google-cloud-retail/v2/protos/google/cloud/retail/v2/model.proto b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/model.proto deleted file mode 100644 index 85b64fcea52..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/model.proto +++ /dev/null @@ -1,239 +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/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2"; -option go_package = "cloud.google.com/go/retail/apiv2/retailpb;retailpb"; -option java_multiple_files = true; -option java_outer_classname = "ModelProto"; -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 that describes the training and serving parameters of a -// [Model][google.cloud.retail.v2.Model]. A -// [Model][google.cloud.retail.v2.Model] can be associated with a -// [ServingConfig][google.cloud.retail.v2.ServingConfig] and then queried -// through the Predict API. -message Model { - option (google.api.resource) = { - type: "retail.googleapis.com/Model" - pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}" - }; - - // Represents an ordered combination of valid serving configs, which - // can be used for `PAGE_OPTIMIZATION` recommendations. - message ServingConfigList { - // Optional. A set of valid serving configs that may be used for - // `PAGE_OPTIMIZATION`. - repeated string serving_config_ids = 1 - [(google.api.field_behavior) = OPTIONAL]; - } - - // The serving state of the model. - enum ServingState { - // Unspecified serving state. - SERVING_STATE_UNSPECIFIED = 0; - - // The model is not serving. - INACTIVE = 1; - - // The model is serving and can be queried. - ACTIVE = 2; - - // The model is trained on tuned hyperparameters and can be - // queried. - TUNED = 3; - } - - // The training state of the model. - enum TrainingState { - // Unspecified training state. - TRAINING_STATE_UNSPECIFIED = 0; - - // The model training is paused. - PAUSED = 1; - - // The model is training. - TRAINING = 2; - } - - // Describes whether periodic tuning is enabled for this model - // or not. Periodic tuning is scheduled at most every three months. You can - // start a tuning process manually by using the `TuneModel` - // method, which starts a tuning process immediately and resets the quarterly - // schedule. Enabling or disabling periodic tuning does not affect any - // current tuning processes. - enum PeriodicTuningState { - // Unspecified default value, should never be explicitly set. - PERIODIC_TUNING_STATE_UNSPECIFIED = 0; - - // The model has periodic tuning disabled. Tuning - // can be reenabled by calling the `EnableModelPeriodicTuning` - // method or by calling the `TuneModel` method. - PERIODIC_TUNING_DISABLED = 1; - - // The model cannot be tuned with periodic tuning OR the - // `TuneModel` method. Hide the options in customer UI and - // reject any requests through the backend self serve API. - ALL_TUNING_DISABLED = 3; - - // The model has periodic tuning enabled. Tuning - // can be disabled by calling the `DisableModelPeriodicTuning` - // method. - PERIODIC_TUNING_ENABLED = 2; - } - - // Describes whether this model have sufficient training data - // to be continuously trained. - enum DataState { - // Unspecified default value, should never be explicitly set. - DATA_STATE_UNSPECIFIED = 0; - - // The model has sufficient training data. - DATA_OK = 1; - - // The model does not have sufficient training data. Error - // messages can be queried via Stackdriver. - DATA_ERROR = 2; - } - - // Required. The fully qualified resource name of the model. - // - // Format: - // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` - // catalog_id has char limit of 50. - // recommendation_model_id has char limit of 40. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The display name of the model. - // - // Should be human readable, used to display Recommendation Models in the - // Retail Cloud Console Dashboard. UTF-8 encoded string with limit of 1024 - // characters. - string display_name = 2 [(google.api.field_behavior) = REQUIRED]; - - // Optional. The training state that the model is in (e.g. - // `TRAINING` or `PAUSED`). - // - // Since part of the cost of running the service - // is frequency of training - this can be used to determine when to train - // model in order to control cost. If not specified: the default value for - // `CreateModel` method is `TRAINING`. The default value for - // `UpdateModel` method is to keep the state the same as before. - TrainingState training_state = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Output only. The serving state of the model: `ACTIVE`, `NOT_ACTIVE`. - ServingState serving_state = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Timestamp the Recommendation Model was created at. - google.protobuf.Timestamp create_time = 5 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Timestamp the Recommendation Model was last updated. E.g. - // if a Recommendation Model was paused - this would be the time the pause was - // initiated. - google.protobuf.Timestamp update_time = 6 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Required. The type of model e.g. `home-page`. - // - // Currently supported values: `recommended-for-you`, `others-you-may-like`, - // `frequently-bought-together`, `page-optimization`, `similar-items`, - // `buy-it-again`, `on-sale-items`, and `recently-viewed`(readonly value). - // - // - // This field together with - // [optimization_objective][google.cloud.retail.v2.Model.optimization_objective] - // describe model metadata to use to control model training and serving. - // See https://cloud.google.com/retail/docs/models - // for more details on what the model metadata control and which combination - // of parameters are valid. For invalid combinations of parameters (e.g. type - // = `frequently-bought-together` and optimization_objective = `ctr`), you - // receive an error 400 if you try to create/update a recommendation with - // this set of knobs. - string type = 7 [(google.api.field_behavior) = REQUIRED]; - - // Optional. The optimization objective e.g. `cvr`. - // - // Currently supported - // values: `ctr`, `cvr`, `revenue-per-order`. - // - // If not specified, we choose default based on model type. - // Default depends on type of recommendation: - // - // `recommended-for-you` => `ctr` - // - // `others-you-may-like` => `ctr` - // - // `frequently-bought-together` => `revenue_per_order` - // - // This field together with - // [optimization_objective][google.cloud.retail.v2.Model.type] - // describe model metadata to use to control model training and serving. - // See https://cloud.google.com/retail/docs/models - // for more details on what the model metadata control and which combination - // of parameters are valid. For invalid combinations of parameters (e.g. type - // = `frequently-bought-together` and optimization_objective = `ctr`), you - // receive an error 400 if you try to create/update a recommendation with - // this set of knobs. - string optimization_objective = 8 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The state of periodic tuning. - // - // The period we use is 3 months - to do a - // one-off tune earlier use the `TuneModel` method. Default value - // is `PERIODIC_TUNING_ENABLED`. - PeriodicTuningState periodic_tuning_state = 11 - [(google.api.field_behavior) = OPTIONAL]; - - // Output only. The timestamp when the latest successful tune finished. - google.protobuf.Timestamp last_tune_time = 12 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The tune operation associated with the model. - // - // Can be used to determine if there is an ongoing tune for this - // recommendation. Empty field implies no tune is goig on. - string tuning_operation = 15 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The state of data requirements for this model: `DATA_OK` and - // `DATA_ERROR`. - // - // Recommendation model cannot be trained if the data is in - // `DATA_ERROR` state. Recommendation model can have `DATA_ERROR` state even - // if serving state is `ACTIVE`: models were trained successfully before, but - // cannot be refreshed because model no longer has sufficient - // data for training. - DataState data_state = 16 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. If `RECOMMENDATIONS_FILTERING_ENABLED`, recommendation filtering - // by attributes is enabled for the model. - RecommendationsFilteringOption filtering_option = 18 - [(google.api.field_behavior) = OPTIONAL]; - - // Output only. The list of valid serving configs associated with the - // PageOptimizationConfig. - repeated ServingConfigList serving_config_lists = 19 - [(google.api.field_behavior) = OUTPUT_ONLY]; -} diff --git a/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/model_service.proto b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/model_service.proto deleted file mode 100644 index 488cf8d74e1..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/model_service.proto +++ /dev/null @@ -1,262 +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/model.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2"; -option go_package = "cloud.google.com/go/retail/apiv2/retailpb;retailpb"; -option java_multiple_files = true; -option java_outer_classname = "ModelServiceProto"; -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 performing CRUD operations on models. -// Recommendation models contain all the metadata necessary to generate a set of -// models for the `Predict()` API. A model is queried -// indirectly via a ServingConfig, which associates a model with a -// given Placement (e.g. Frequently Bought Together on Home Page). -// -// This service allows you to do the following: -// -// * Initiate training of a model. -// * Pause training of an existing model. -// * List all the available models along with their metadata. -// * Control their tuning schedule. -service ModelService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Creates a new model. - rpc CreateModel(CreateModelRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2/{parent=projects/*/locations/*/catalogs/*}/models" - body: "model" - }; - option (google.api.method_signature) = "parent,model"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2.Model" - metadata_type: "google.cloud.retail.v2.CreateModelMetadata" - }; - } - - // Gets a model. - rpc GetModel(GetModelRequest) returns (Model) { - option (google.api.http) = { - get: "/v2/{name=projects/*/locations/*/catalogs/*/models/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Pauses the training of an existing model. - rpc PauseModel(PauseModelRequest) returns (Model) { - option (google.api.http) = { - post: "/v2/{name=projects/*/locations/*/catalogs/*/models/*}:pause" - body: "*" - }; - option (google.api.method_signature) = "name"; - } - - // Resumes the training of an existing model. - rpc ResumeModel(ResumeModelRequest) returns (Model) { - option (google.api.http) = { - post: "/v2/{name=projects/*/locations/*/catalogs/*/models/*}:resume" - body: "*" - }; - option (google.api.method_signature) = "name"; - } - - // Deletes an existing model. - rpc DeleteModel(DeleteModelRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v2/{name=projects/*/locations/*/catalogs/*/models/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists all the models linked to this event store. - rpc ListModels(ListModelsRequest) returns (ListModelsResponse) { - option (google.api.http) = { - get: "/v2/{parent=projects/*/locations/*/catalogs/*}/models" - }; - option (google.api.method_signature) = "parent"; - } - - // Update of model metadata. Only fields that - // currently can be updated are: `filtering_option` and - // `periodic_tuning_state`. - // If other values are provided, this API method ignores them. - rpc UpdateModel(UpdateModelRequest) returns (Model) { - option (google.api.http) = { - patch: "/v2/{model.name=projects/*/locations/*/catalogs/*/models/*}" - body: "model" - }; - option (google.api.method_signature) = "model,update_mask"; - } - - // Tunes an existing model. - rpc TuneModel(TuneModelRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2/{name=projects/*/locations/*/catalogs/*/models/*}:tune" - body: "*" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2.TuneModelResponse" - metadata_type: "google.cloud.retail.v2.TuneModelMetadata" - }; - } -} - -// Request for creating a model. -message CreateModelRequest { - // Required. The parent resource under which to create the model. 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 payload of the [Model][google.cloud.retail.v2.Model] to - // create. - Model model = 2 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Whether to run a dry run to validate the request (without - // actually creating the model). - bool dry_run = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// Request for updating an existing model. -message UpdateModelRequest { - // Required. The body of the updated [Model][google.cloud.retail.v2.Model]. - Model model = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Indicates which fields in the provided 'model' to - // update. If not set, by default updates all fields. - google.protobuf.FieldMask update_mask = 2 - [(google.api.field_behavior) = OPTIONAL]; -} - -// Request for getting a model. -message GetModelRequest { - // Required. The resource name of the [Model][google.cloud.retail.v2.Model] to - // get. Format: - // `projects/{project_number}/locations/{location_id}/catalogs/{catalog}/models/{model_id}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Model" } - ]; -} - -// Request for pausing training of a model. -message PauseModelRequest { - // Required. The name of the model to pause. - // Format: - // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Model" } - ]; -} - -// Request for resuming training of a model. -message ResumeModelRequest { - // Required. The name of the model to resume. - // Format: - // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for listing models associated with a resource. -message ListModelsRequest { - // Required. The parent for which to list models. - // 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 `ListModels` - // call. Provide this to retrieve the subsequent page. - string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// Request for deleting a model. -message DeleteModelRequest { - // Required. The resource name of the [Model][google.cloud.retail.v2.Model] to - // delete. Format: - // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Model" } - ]; -} - -// Response to a ListModelRequest. -message ListModelsResponse { - // List of Models. - repeated Model models = 1; - - // Pagination token, if not returned indicates the last page. - string next_page_token = 2; -} - -// Request to manually start a tuning process now (instead of waiting for -// the periodically scheduled tuning to happen). -message TuneModelRequest { - // Required. The resource name of the model to tune. - // Format: - // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Model" } - ]; -} - -// Metadata associated with a create operation. -message CreateModelMetadata { - // The resource name of the model that this create applies to. - // Format: - // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` - string model = 1; -} - -// Metadata associated with a tune operation. -message TuneModelMetadata { - // The resource name of the model that this tune applies to. - // Format: - // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` - string model = 1; -} - -// Response associated with a tune operation. -message TuneModelResponse {} diff --git a/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/prediction_service.proto b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/prediction_service.proto deleted file mode 100644 index 6e8061726ca..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/prediction_service.proto +++ /dev/null @@ -1,226 +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/user_event.proto"; -import "google/protobuf/struct.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2"; -option go_package = "cloud.google.com/go/retail/apiv2/retailpb;retailpb"; -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: "*" - additional_bindings { - post: "/v2/{placement=projects/*/locations/*/catalogs/*/servingConfigs/*}:predict" - body: "*" - } - }; - } -} - -// Request message for Predict method. -message PredictRequest { - // Required. Full resource name of the format: - // `{placement=projects/*/locations/global/catalogs/default_catalog/servingConfigs/*}` - // or - // `{placement=projects/*/locations/global/catalogs/default_catalog/placements/*}`. - // We recommend using the `servingConfigs` resource. `placements` is a legacy - // resource. - // The ID of the Recommendations AI serving config or placement. - // Before you can request predictions from your model, you must create at - // least one serving config or placement for it. For more information, see - // [Manage serving configs] - // (https://cloud.google.com/retail/docs/manage-configs). - // - // The full list of available serving configs can be seen at - // https://console.cloud.google.com/ai/retail/catalogs/default_catalog/configs - 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. 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; - - // This field is not used; leave it unset. - string page_token = 4 [deprecated = true]; - - // 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 *no* - // results. If instead you want empty result sets to return generic - // (unfiltered) popular products, set `strictFiltering` to False in - // `PredictRequest.params`. Note that the API will never return items with - // storageStatus of "EXPIRED" or "DELETED" regardless of filter choices. - // - // If `filterSyntaxV2` is set to true under the `params` field, then - // attribute-based expressions are expected instead of the above described - // tag-based syntax. Examples: - // - // * (colors: ANY("Red", "Blue")) AND NOT (categories: ANY("Phones")) - // * (availability: ANY("IN_STOCK")) AND - // (colors: ANY("Red") OR categories: ANY("Phones")) - // - // For more information, see - // [Filter recommendations](https://cloud.google.com/retail/docs/filter-recs). - 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 a 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. - // * `filterSyntaxV2`: Boolean. False by default. If set to true, the `filter` - // field is interpreteted according to the new, attribute-based syntax. - 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/google-cloud-retail/v2/protos/google/cloud/retail/v2/product.proto b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/product.proto deleted file mode 100644 index f1ec4869508..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/product.proto +++ /dev/null @@ -1,586 +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 = "cloud.google.com/go/retail/apiv2/retailpb;retailpb"; -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]. Note - // that this is only applicable to - // [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] and - // [Type.COLLECTION][google.cloud.retail.v2.Product.Type.COLLECTION], and - // ignored for [Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT]. - // In general, we suggest the users to delete the stale products explicitly, - // instead of using this field to determine staleness. - // - // 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. Note that this is only - // applicable to [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] - // and [Type.COLLECTION][google.cloud.retail.v2.Product.Type.COLLECTION], - // and ignored for - // [Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT]. In general, - // we suggest the users to delete the stale products explicitly, instead of - // using this field to determine staleness. - // - // 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 an - // 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, 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]. Note - // that this is only applicable to - // [Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY] and - // [Type.COLLECTION][google.cloud.retail.v2.Product.Type.COLLECTION], and - // ignored for [Type.VARIANT][google.cloud.retail.v2.Product.Type.VARIANT]. - 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. - // - // This field is deprecated. Use the retrievable site-wide control instead. - google.protobuf.FieldMask retrievable_fields = 30 [deprecated = true]; - - // 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]; - - // Output only. A list of local inventories specific to different places. - // - // This field can be managed by - // [ProductService.AddLocalInventories][google.cloud.retail.v2.ProductService.AddLocalInventories] - // and - // [ProductService.RemoveLocalInventories][google.cloud.retail.v2.ProductService.RemoveLocalInventories] - // APIs if fine-grained, high-volume updates are necessary. - repeated LocalInventory local_inventories = 35 - [(google.api.field_behavior) = OUTPUT_ONLY]; -} diff --git a/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/product_service.proto b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/product_service.proto deleted file mode 100644 index ff69b68c7b4..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/product_service.proto +++ /dev/null @@ -1,921 +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 = "cloud.google.com/go/retail/apiv2/retailpb;retailpb"; -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 is 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 - // [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] - // or - // [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. - // - // When inventory is updated with - // [ProductService.CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] - // and - // [ProductService.UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct], - // the specified inventory field value(s) overwrite any existing value(s) - // while ignoring the last update time for this field. Furthermore, the last - // update times for the specified inventory fields are overwritten by the - // times of the - // [ProductService.CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] - // or - // [ProductService.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 is used. - // - // If no inventory fields are set in - // [SetInventoryRequest.set_mask][google.cloud.retail.v2.SetInventoryRequest.set_mask], - // then any existing inventory information is preserved. - // - // Pre-existing inventory information can only be updated with - // [ProductService.SetInventory][google.cloud.retail.v2.ProductService.SetInventory], - // [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2.ProductService.AddFulfillmentPlaces], - // and - // [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces]. - // - // The returned [Operation][google.longrunning.Operation]s is obsolete after - // one day, and the [GetOperation][google.longrunning.Operations.GetOperation] - // API returns `NOT_FOUND` afterwards. - // - // If conflicting updates are issued, the - // [Operation][google.longrunning.Operation]s associated with the stale - // updates are not marked as [done][google.longrunning.Operation.done] until - // they are obsolete. - 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" - }; - } - - // It is recommended to use the - // [ProductService.AddLocalInventories][google.cloud.retail.v2.ProductService.AddLocalInventories] - // method instead of - // [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2.ProductService.AddFulfillmentPlaces]. - // [ProductService.AddLocalInventories][google.cloud.retail.v2.ProductService.AddLocalInventories] - // achieves the same results but provides more fine-grained control over - // ingesting local inventory data. - // - // 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 - // [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] - // or - // [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. - // - // The returned [Operation][google.longrunning.Operation]s will be obsolete - // after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] - // API will return NOT_FOUND afterwards. - // - // If conflicting updates are issued, the - // [Operation][google.longrunning.Operation]s associated with the stale - // updates will not be marked as [done][google.longrunning.Operation.done] - // until being obsolete. - 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" - }; - } - - // It is recommended to use the - // [ProductService.RemoveLocalInventories][google.cloud.retail.v2.ProductService.RemoveLocalInventories] - // method instead of - // [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces]. - // [ProductService.RemoveLocalInventories][google.cloud.retail.v2.ProductService.RemoveLocalInventories] - // achieves the same results but provides more fine-grained control over - // ingesting local inventory data. - // - // 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 - // [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] - // or - // [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. - // - // The returned [Operation][google.longrunning.Operation]s will be obsolete - // after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] - // API will return NOT_FOUND afterwards. - // - // If conflicting updates are issued, the - // [Operation][google.longrunning.Operation]s associated with the stale - // updates will not be marked as [done][google.longrunning.Operation.done] - // until being obsolete. - 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 - // [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] - // or - // [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. - // - // Local inventory information can only be modified using this method. - // [ProductService.CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] - // and - // [ProductService.UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] - // has no effect on local inventories. - // - // The returned [Operation][google.longrunning.Operation]s will be obsolete - // after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] - // API will return NOT_FOUND afterwards. - // - // If conflicting updates are issued, the - // [Operation][google.longrunning.Operation]s associated with the stale - // updates will not be marked as [done][google.longrunning.Operation.done] - // until being obsolete. - 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 - // [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] - // or - // [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. - // - // Local inventory information can only be removed using this method. - // [ProductService.CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] - // and - // [ProductService.UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] - // has no effect on local inventories. - // - // The returned [Operation][google.longrunning.Operation]s will be obsolete - // after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] - // API will return NOT_FOUND afterwards. - // - // If conflicting updates are issued, the - // [Operation][google.longrunning.Operation]s associated with the stale - // updates will not be marked as [done][google.longrunning.Operation.done] - // until being obsolete. - 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 -// [ProductService.CreateProduct][google.cloud.retail.v2.ProductService.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 -// [ProductService.GetProduct][google.cloud.retail.v2.ProductService.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 -// [ProductService.UpdateProduct][google.cloud.retail.v2.ProductService.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 -// [ProductService.DeleteProduct][google.cloud.retail.v2.ProductService.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 -// [ProductService.SetInventory][google.cloud.retail.v2.ProductService.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][google.cloud.retail.v2.Product.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][google.cloud.retail.v2.Product.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][google.cloud.retail.v2.Product.fulfillment_info] - // * Checks that only the desired fulfillment info types have empty - // [SetInventoryRequest.inventory.fulfillment_info.place_ids][google.cloud.retail.v2.FulfillmentInfo.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, - // [ProductService.UpdateProduct][google.cloud.retail.v2.ProductService.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 -// [ProductService.SetInventory][google.cloud.retail.v2.ProductService.SetInventory] -// method. -message SetInventoryMetadata {} - -// Response of the SetInventoryRequest. Currently empty because -// there is no meaningful response populated from the -// [ProductService.SetInventory][google.cloud.retail.v2.ProductService.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][google.cloud.retail.v2.FulfillmentInfo.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 -// [ProductService.RemoveLocalInventories][google.cloud.retail.v2.ProductService.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 -// [ProductService.RemoveLocalInventories][google.cloud.retail.v2.ProductService.RemoveLocalInventories] -// method. -message RemoveLocalInventoriesMetadata {} - -// Response of the -// [ProductService.RemoveLocalInventories][google.cloud.retail.v2.ProductService.RemoveLocalInventories] -// API. Currently empty because there is no meaningful response populated from -// the -// [ProductService.RemoveLocalInventories][google.cloud.retail.v2.ProductService.RemoveLocalInventories] -// method. -message RemoveLocalInventoriesResponse {} - -// Request message for -// [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2.ProductService.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 -// [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces] -// method. -message RemoveFulfillmentPlacesMetadata {} - -// Response of the RemoveFulfillmentPlacesRequest. Currently empty because there -// is no meaningful response populated from the -// [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces] -// method. -message RemoveFulfillmentPlacesResponse {} diff --git a/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/promotion.proto b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/promotion.proto deleted file mode 100644 index 26694384515..00000000000 --- a/owl-bot-staging/google-cloud-retail/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 = "cloud.google.com/go/retail/apiv2/retailpb;retailpb"; -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/google-cloud-retail/v2/protos/google/cloud/retail/v2/purge_config.proto b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/purge_config.proto deleted file mode 100644 index fe6272d5d9d..00000000000 --- a/owl-bot-staging/google-cloud-retail/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 = "cloud.google.com/go/retail/apiv2/retailpb;retailpb"; -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/google-cloud-retail/v2/protos/google/cloud/retail/v2/search_service.proto b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/search_service.proto deleted file mode 100644 index d25d2849970..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/search_service.proto +++ /dev/null @@ -1,985 +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 = "cloud.google.com/go/retail/apiv2/retailpb;retailpb"; -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"; -option (google.api.resource_definition) = { - type: "retail.googleapis.com/Experiment" - pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/experiments/{experiment}" -}; - -// Service for search. -// -// This feature is only available for users who have Retail Search enabled. -// 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. - // 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: "*" - additional_bindings { - post: "/v2/{placement=projects/*/locations/*/catalogs/*/servingConfigs/*}: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 40. - // - // For all numerical facet keys that appear in the list of products from - // the catalog, the percentiles 0, 10, 30, 50, 70, 90 and 100 are - // computed from their distribution weekly. If the model assigns a high - // score to a numerical facet key and its intervals are not specified in - // the search request, these percentiles will become the bounds - // for its intervals and will be returned in the response. If the - // facet key intervals are specified in the request, then the specified - // intervals will be returned instead. - 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; - - // True to make facet keys case insensitive when getting faceting - // values with prefixes or contains; false otherwise. - bool case_insensitive = 10; - - // The order in which - // [SearchResponse.Facet.values][google.cloud.retail.v2.SearchResponse.Facet.values] - // are returned. - // - // Allowed values are: - // - // * "count desc", which means order by - // [SearchResponse.Facet.values.count][google.cloud.retail.v2.SearchResponse.Facet.FacetValue.count] - // descending. - // - // * "value desc", which means order by - // [SearchResponse.Facet.values.value][google.cloud.retail.v2.SearchResponse.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, - // [SearchResponse.Facet.values.value][google.cloud.retail.v2.SearchResponse.Facet.FacetValue.value] - // will be always "1" and - // [SearchResponse.Facet.values.count][google.cloud.retail.v2.SearchResponse.Facet.FacetValue.count] - // will be the number of results that match 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; - - // Returns the min and max value for each numerical facet intervals. - // Ignored for textual facets. - bool return_min_max = 11; - } - - // 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 50. 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. In this case, server behavior - // 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. In this case, server behavior defaults to - // [Mode.AUTO][google.cloud.retail.v2.SearchRequest.PersonalizationSpec.Mode.AUTO]. - MODE_UNSPECIFIED = 0; - - // Let CRS decide whether to use personalization based on quality of user - // event data. - 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. In this case, server behavior - // 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][google.cloud.retail.v2.SearchResponse.SearchResult] - // and [SearchResponse.Facet][google.cloud.retail.v2.SearchResponse.Facet] - // will be returned. - SEARCH_MODE_UNSPECIFIED = 0; - - // Only product search will be performed. The faceted search will be - // disabled. - // - // Only - // [SearchResponse.SearchResult][google.cloud.retail.v2.SearchResponse.SearchResult] - // will be returned. - // [SearchResponse.Facet][google.cloud.retail.v2.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][google.cloud.retail.v2.SearchResponse.Facet] will - // be returned. - // [SearchResponse.SearchResult][google.cloud.retail.v2.SearchResponse.SearchResult] - // will not be returned. - FACETED_SEARCH_ONLY = 2; - } - - // Required. The resource name of the Retail Search serving config, such as - // `projects/*/locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` - // or the name of the legacy placement resource, such as - // `projects/*/locations/global/catalogs/default_catalog/placements/default_search`. - // This field is used to identify the serving config 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 200 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.v2.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, 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. - // - // Notice that if both - // [ServingConfig.personalization_spec][google.cloud.retail.v2.ServingConfig.personalization_spec] - // and - // [SearchRequest.personalization_spec][google.cloud.retail.v2.SearchRequest.personalization_spec] - // are set. - // [SearchRequest.personalization_spec][google.cloud.retail.v2.SearchRequest.personalization_spec] - // will override - // [ServingConfig.personalization_spec][google.cloud.retail.v2.ServingConfig.personalization_spec]. - 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; - - // The entity for customers that may run multiple different entities, domains, - // sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, - // `google.com`, `youtube.com`, etc. - // If this is set, it should be exactly matched with - // [UserEvent.entity][google.cloud.retail.v2.UserEvent.entity] to get search - // results boosted by entity. - string entity = 38; -} - -// 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; - - // Specifies previous events related to this product for this user based on - // [UserEvent][google.cloud.retail.v2.UserEvent] with same - // [SearchRequest.visitor_id][google.cloud.retail.v2.SearchRequest.visitor_id] - // or [UserInfo.user_id][google.cloud.retail.v2.UserInfo.user_id]. - // - // This is set only when - // [SearchRequest.PersonalizationSpec.mode][google.cloud.retail.v2.SearchRequest.PersonalizationSpec.mode] - // is - // [SearchRequest.PersonalizationSpec.Mode.AUTO][google.cloud.retail.v2.SearchRequest.PersonalizationSpec.Mode.AUTO]. - // - // Possible values: - // - // * `purchased`: Indicates that this product has been purchased before. - repeated string personal_labels = 7; - } - - // 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 minimum value in the - // [FacetValue.interval][google.cloud.retail.v2.SearchResponse.Facet.FacetValue.interval]. - // Only supported on numerical facets and returned if - // [SearchRequest.FacetSpec.FacetKey.return_min_max][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.return_min_max] - // is true. - double min_value = 5; - - // The maximum value in the - // [FacetValue.interval][google.cloud.retail.v2.SearchResponse.Facet.FacetValue.interval]. - // Only supported on numerical facets and returned if - // [SearchRequest.FacetSpec.FacetKey.return_min_max][google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey.return_min_max] - // is true. - double max_value = 6; - } - - // 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 is 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; - - // Metadata related to A/B testing [Experiment][] associated with this - // response. Only exists when an experiment is triggered. - repeated ExperimentInfo experiment_info = 17; -} - -// Metadata for active A/B testing [Experiments][]. -message ExperimentInfo { - // Metadata for active serving config A/B tests. - message ServingConfigExperiment { - // The fully qualified resource name of the original - // [SearchRequest.placement][google.cloud.retail.v2.SearchRequest.placement] - // in the search request prior to reassignment by experiment API. For - // example: `projects/*/locations/*/catalogs/*/servingConfigs/*`. - string original_serving_config = 1 [(google.api.resource_reference) = { - type: "retail.googleapis.com/ServingConfig" - }]; - - // The fully qualified resource name of the serving config - // [VariantArm.serving_config_id][] responsible for generating the search - // response. For example: - // `projects/*/locations/*/catalogs/*/servingConfigs/*`. - string experiment_serving_config = 2 [(google.api.resource_reference) = { - type: "retail.googleapis.com/ServingConfig" - }]; - } - - // Information associated with the specific experiment entity being recorded. - oneof experiment_metadata { - // A/B test between existing Cloud Retail Search - // [ServingConfig][google.cloud.retail.v2.ServingConfig]s. - ServingConfigExperiment serving_config_experiment = 2; - } - - // The fully qualified resource name of the experiment that provides the - // serving config under test, should an active experiment exist. For example: - // `projects/*/locations/global/catalogs/default_catalog/experiments/experiment_id` - string experiment = 1 [(google.api.resource_reference) = { - type: "retail.googleapis.com/Experiment" - }]; -} diff --git a/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/serving_config.proto b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/serving_config.proto deleted file mode 100644 index ef5b46fca2b..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/serving_config.proto +++ /dev/null @@ -1,265 +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/search_service.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2"; -option go_package = "cloud.google.com/go/retail/apiv2/retailpb;retailpb"; -option java_multiple_files = true; -option java_outer_classname = "ServingConfigProto"; -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 metadata that is used to generate serving time results (e.g. -// search results or recommendation predictions). -message ServingConfig { - option (google.api.resource) = { - type: "retail.googleapis.com/ServingConfig" - pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}" - }; - - // What type of diversity - data or rule based. - enum DiversityType { - // Default value. - DIVERSITY_TYPE_UNSPECIFIED = 0; - - // Rule based diversity. - RULE_BASED_DIVERSITY = 2; - - // Data driven diversity. - DATA_DRIVEN_DIVERSITY = 3; - } - - // 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 in the same [Catalog][google.cloud.retail.v2.Catalog] - // 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.v2.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-reranking` - // * `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.v2.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.v2.Control] - // resources with only the Facet control set. These controls are assumed to be - // in the same [Catalog][google.cloud.retail.v2.Catalog] as the - // [ServingConfig][google.cloud.retail.v2.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.v2.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.v2.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.v2.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. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2.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.v2.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.v2.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.v2.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.v2.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.v2.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.v2.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.v2.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.v2.ServingConfig.solution_types] is - // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. - string diversity_level = 8; - - // What kind of diversity to use - data driven or rule based. If unset, the - // server behavior defaults to - // [RULE_BASED_DIVERSITY][google.cloud.retail.v2.ServingConfig.DiversityType.RULE_BASED_DIVERSITY]. - DiversityType diversity_type = 20; - - // 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.v2.ServingConfig.solution_types] is - // [SOLUTION_TYPE_RECOMMENDATION][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_RECOMMENDATION]. - string enable_category_filter_level = 16; - - // The specification for personalization spec. - // - // Can only be set if - // [solution_types][google.cloud.retail.v2.ServingConfig.solution_types] is - // [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2main.SolutionType.SOLUTION_TYPE_SEARCH]. - // - // Notice that if both - // [ServingConfig.personalization_spec][google.cloud.retail.v2.ServingConfig.personalization_spec] - // and - // [SearchRequest.personalization_spec][google.cloud.retail.v2.SearchRequest.personalization_spec] - // are set. - // [SearchRequest.personalization_spec][google.cloud.retail.v2.SearchRequest.personalization_spec] - // will override - // [ServingConfig.personalization_spec][google.cloud.retail.v2.ServingConfig.personalization_spec]. - SearchRequest.PersonalizationSpec personalization_spec = 21; - - // 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/google-cloud-retail/v2/protos/google/cloud/retail/v2/serving_config_service.proto b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/serving_config_service.proto deleted file mode 100644 index 25ca897f306..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/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.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/serving_config.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2"; -option go_package = "cloud.google.com/go/retail/apiv2/retailpb;retailpb"; -option java_multiple_files = true; -option java_outer_classname = "ServingConfigServiceProto"; -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 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.v2.ServingConfig]s are - // allowed in a [Catalog][google.cloud.retail.v2.Catalog], otherwise a - // FAILED_PRECONDITION error is returned. - rpc CreateServingConfig(CreateServingConfigRequest) returns (ServingConfig) { - option (google.api.http) = { - post: "/v2/{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: "/v2/{name=projects/*/locations/*/catalogs/*/servingConfigs/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Updates a ServingConfig. - rpc UpdateServingConfig(UpdateServingConfigRequest) returns (ServingConfig) { - option (google.api.http) = { - patch: "/v2/{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: "/v2/{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: "/v2/{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: "/v2/{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: "/v2/{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.v2.ServingConfig] to update. The - // following are NOT supported: - // - // * [ServingConfig.name][google.cloud.retail.v2.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/google-cloud-retail/v2/protos/google/cloud/retail/v2/user_event.proto b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/user_event.proto deleted file mode 100644 index 1ddc8bd6178..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/user_event.proto +++ /dev/null @@ -1,350 +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 = "cloud.google.com/go/retail/apiv2/retailpb;retailpb"; -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, 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; - - // The entity for customers that may run multiple different entities, domains, - // sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, - // `google.com`, `youtube.com`, etc. - // It is recommended to set this field to get better per-entity search, - // completion and prediction results. - string entity = 23; -} - -// 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/google-cloud-retail/v2/protos/google/cloud/retail/v2/user_event_service.proto b/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/user_event_service.proto deleted file mode 100644 index 719fdaa2d43..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/protos/google/cloud/retail/v2/user_event_service.proto +++ /dev/null @@ -1,210 +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 = "cloud.google.com/go/retail/apiv2/retailpb;retailpb"; -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 - // are not annotated with detailed product information for products that are - // missing from the catalog when the user event is ingested. These - // events are stored as unjoined events with limited usage on training and - // serving. You can use this method to start a join operation on specified - // events with the latest version of product catalog. You can also use this - // method 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]; - - // If set to true, the user event will be written asynchronously after - // validation, and the API will respond without waiting for the write. - // Therefore, silent failures can occur even if the API returns success. In - // case of silent failures, error messages can be found in Stackdriver logs. - bool write_async = 3; -} - -// Request message for CollectUserEvent method. -message CollectUserEventRequest { - // The rule that can convert the raw_json to a user event. It is needed - // only when the raw_json is set. - oneof conversion_rule { - // The prebuilt rule name that can convert a specific type of raw_json. - // For example: "ga4_bq" rule for the GA4 user event schema. - string prebuilt_rule = 6; - } - - // 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; - - // An arbitrary serialized JSON string that contains necessary information - // that can comprise a user event. When this field is specified, the - // user_event field will be ignored. Note: line-delimited JSON is not - // supported, a single JSON only. - string raw_json = 5; -} - -// 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/google-cloud-retail/v2/samples/generated/v2/catalog_service.add_catalog_attribute.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.add_catalog_attribute.js deleted file mode 100644 index fb7a8fe38d5..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.add_catalog_attribute.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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_v2_generated_CatalogService_AddCatalogAttribute_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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.v2.CatalogAttribute - * to add. - */ - // const catalogAttribute = {} - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2; - - // 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_v2_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/google-cloud-retail/v2/samples/generated/v2/catalog_service.get_attributes_config.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.get_attributes_config.js deleted file mode 100644 index fa8e639ec77..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.get_attributes_config.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by 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_CatalogService_GetAttributesConfig_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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').v2; - - // 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_v2_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/google-cloud-retail/v2/samples/generated/v2/catalog_service.get_completion_config.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.get_completion_config.js deleted file mode 100644 index c5bc650ded5..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.get_completion_config.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by 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_CatalogService_GetCompletionConfig_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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').v2; - - // 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_v2_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/google-cloud-retail/v2/samples/generated/v2/catalog_service.get_default_branch.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.get_default_branch.js deleted file mode 100644 index 04e61acded0..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.get_default_branch.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2/samples/generated/v2/catalog_service.list_catalogs.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.list_catalogs.js deleted file mode 100644 index 74c743460e8..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.list_catalogs.js +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2/samples/generated/v2/catalog_service.remove_catalog_attribute.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.remove_catalog_attribute.js deleted file mode 100644 index 295f155f0b9..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.remove_catalog_attribute.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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_v2_generated_CatalogService_RemoveCatalogAttribute_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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.v2.CatalogAttribute to remove. - */ - // const key = 'abc123' - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2; - - // 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_v2_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/google-cloud-retail/v2/samples/generated/v2/catalog_service.replace_catalog_attribute.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.replace_catalog_attribute.js deleted file mode 100644 index 623955dd3f7..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.replace_catalog_attribute.js +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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_v2_generated_CatalogService_ReplaceCatalogAttribute_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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.v2.CatalogAttribute. - */ - // const catalogAttribute = {} - /** - * Indicates which fields in the provided - * CatalogAttribute google.cloud.retail.v2.CatalogAttribute to update. The - * following are NOT supported: - * * CatalogAttribute.key google.cloud.retail.v2.CatalogAttribute.key - * If not set, all supported fields are updated. - */ - // const updateMask = {} - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2; - - // 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_v2_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/google-cloud-retail/v2/samples/generated/v2/catalog_service.set_default_branch.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.set_default_branch.js deleted file mode 100644 index f1919ac27e9..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.set_default_branch.js +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2/samples/generated/v2/catalog_service.update_attributes_config.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.update_attributes_config.js deleted file mode 100644 index a4ce6ca300d..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.update_attributes_config.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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_v2_generated_CatalogService_UpdateAttributesConfig_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The AttributesConfig google.cloud.retail.v2.AttributesConfig - * to update. - */ - // const attributesConfig = {} - /** - * Indicates which fields in the provided - * AttributesConfig google.cloud.retail.v2.AttributesConfig to update. The - * following is the only supported field: - * * AttributesConfig.catalog_attributes google.cloud.retail.v2.AttributesConfig.catalog_attributes - * If not set, all supported fields are updated. - */ - // const updateMask = {} - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2; - - // 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_v2_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/google-cloud-retail/v2/samples/generated/v2/catalog_service.update_catalog.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.update_catalog.js deleted file mode 100644 index 731c8e4846c..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.update_catalog.js +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2/samples/generated/v2/catalog_service.update_completion_config.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.update_completion_config.js deleted file mode 100644 index 9e8591755ed..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/catalog_service.update_completion_config.js +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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_v2_generated_CatalogService_UpdateCompletionConfig_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The CompletionConfig google.cloud.retail.v2.CompletionConfig - * to update. - * If the caller does not have permission to update the - * CompletionConfig google.cloud.retail.v2.CompletionConfig, then a - * PERMISSION_DENIED error is returned. - * If the CompletionConfig google.cloud.retail.v2.CompletionConfig to - * update does not exist, a NOT_FOUND error is returned. - */ - // const completionConfig = {} - /** - * Indicates which fields in the provided - * CompletionConfig google.cloud.retail.v2.CompletionConfig to update. The - * following are the only supported fields: - * * CompletionConfig.matching_order google.cloud.retail.v2.CompletionConfig.matching_order - * * CompletionConfig.max_suggestions google.cloud.retail.v2.CompletionConfig.max_suggestions - * * CompletionConfig.min_prefix_length google.cloud.retail.v2.CompletionConfig.min_prefix_length - * * CompletionConfig.auto_learning google.cloud.retail.v2.CompletionConfig.auto_learning - * If not set, all supported fields are updated. - */ - // const updateMask = {} - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2; - - // 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_v2_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/google-cloud-retail/v2/samples/generated/v2/completion_service.complete_query.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/completion_service.complete_query.js deleted file mode 100644 index e9c66ec9520..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/completion_service.complete_query.js +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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' - /** - * Note that this field applies for `user-data` dataset only. For requests - * with `cloud-retail` dataset, setting this field has no effect. - * 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. We recommend that you - * leave this field empty. - * It can 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 google.cloud.retail.v2.CompletionConfig.max_suggestions. - * The maximum allowed max suggestions is 20. If it is set higher, it will be - * capped by 20. - */ - // const maxSuggestions = 1234 - /** - * The entity for customers that may run multiple different entities, domains, - * sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, - * `google.com`, `youtube.com`, etc. - * If this is set, it should be exactly matched with - * UserEvent.entity google.cloud.retail.v2.UserEvent.entity to get - * per-entity autocomplete results. - */ - // const entity = 'abc123' - - // 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/google-cloud-retail/v2/samples/generated/v2/completion_service.import_completion_data.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/completion_service.import_completion_data.js deleted file mode 100644 index 78b7b777c51..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/completion_service.import_completion_data.js +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 is sent to - * specified Pub/Sub topic. The message data is 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/google-cloud-retail/v2/samples/generated/v2/control_service.create_control.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/control_service.create_control.js deleted file mode 100644 index 74c6942875e..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/control_service.create_control.js +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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_v2_generated_ControlService_CreateControl_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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').v2; - - // 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_v2_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/google-cloud-retail/v2/samples/generated/v2/control_service.delete_control.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/control_service.delete_control.js deleted file mode 100644 index ab8f41c0d9c..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/control_service.delete_control.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by 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_ControlService_DeleteControl_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the 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').v2; - - // 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_v2_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/google-cloud-retail/v2/samples/generated/v2/control_service.get_control.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/control_service.get_control.js deleted file mode 100644 index dee1cbdef8f..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/control_service.get_control.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by 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_ControlService_GetControl_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the Control to get. 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').v2; - - // 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_v2_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/google-cloud-retail/v2/samples/generated/v2/control_service.list_controls.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/control_service.list_controls.js deleted file mode 100644 index d24b21f0fe7..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/control_service.list_controls.js +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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_ControlService_ListControls_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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.v2.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').v2; - - // 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_v2_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/google-cloud-retail/v2/samples/generated/v2/control_service.update_control.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/control_service.update_control.js deleted file mode 100644 index ea3160f0db8..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/control_service.update_control.js +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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_v2_generated_ControlService_UpdateControl_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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.v2.Control to update. The following are NOT - * supported: - * * Control.name google.cloud.retail.v2.Control.name - * If not set or empty, all supported fields are updated. - */ - // const updateMask = {} - - // Imports the Retail library - const {ControlServiceClient} = require('@google-cloud/retail').v2; - - // 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_v2_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/google-cloud-retail/v2/samples/generated/v2/model_service.create_model.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.create_model.js deleted file mode 100644 index f4a6164f20c..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.create_model.js +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, model) { - // [START retail_v2_generated_ModelService_CreateModel_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent resource under which to create the model. Format: - * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` - */ - // const parent = 'abc123' - /** - * Required. The payload of the Model google.cloud.retail.v2.Model to - * create. - */ - // const model = {} - /** - * Optional. Whether to run a dry run to validate the request (without - * actually creating the model). - */ - // const dryRun = true - - // Imports the Retail library - const {ModelServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new ModelServiceClient(); - - async function callCreateModel() { - // Construct request - const request = { - parent, - model, - }; - - // Run request - const [operation] = await retailClient.createModel(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateModel(); - // [END retail_v2_generated_ModelService_CreateModel_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.delete_model.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.delete_model.js deleted file mode 100644 index 41fd30a399e..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.delete_model.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by 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_ModelService_DeleteModel_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the Model google.cloud.retail.v2.Model to - * delete. Format: - * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` - */ - // const name = 'abc123' - - // Imports the Retail library - const {ModelServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new ModelServiceClient(); - - async function callDeleteModel() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.deleteModel(request); - console.log(response); - } - - callDeleteModel(); - // [END retail_v2_generated_ModelService_DeleteModel_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.get_model.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.get_model.js deleted file mode 100644 index 2624cd11c78..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.get_model.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by 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_ModelService_GetModel_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the Model google.cloud.retail.v2.Model to - * get. Format: - * `projects/{project_number}/locations/{location_id}/catalogs/{catalog}/models/{model_id}` - */ - // const name = 'abc123' - - // Imports the Retail library - const {ModelServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new ModelServiceClient(); - - async function callGetModel() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.getModel(request); - console.log(response); - } - - callGetModel(); - // [END retail_v2_generated_ModelService_GetModel_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.list_models.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.list_models.js deleted file mode 100644 index d0e2713e065..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.list_models.js +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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_ModelService_ListModels_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent for which to list models. - * 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 `ListModels` - * call. Provide this to retrieve the subsequent page. - */ - // const pageToken = 'abc123' - - // Imports the Retail library - const {ModelServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new ModelServiceClient(); - - async function callListModels() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await retailClient.listModelsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListModels(); - // [END retail_v2_generated_ModelService_ListModels_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.pause_model.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.pause_model.js deleted file mode 100644 index 13a1308d15d..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.pause_model.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by 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_ModelService_PauseModel_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the model to pause. - * Format: - * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` - */ - // const name = 'abc123' - - // Imports the Retail library - const {ModelServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new ModelServiceClient(); - - async function callPauseModel() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.pauseModel(request); - console.log(response); - } - - callPauseModel(); - // [END retail_v2_generated_ModelService_PauseModel_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.resume_model.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.resume_model.js deleted file mode 100644 index 2fea1a0cead..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.resume_model.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by 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_ModelService_ResumeModel_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the model to resume. - * Format: - * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` - */ - // const name = 'abc123' - - // Imports the Retail library - const {ModelServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new ModelServiceClient(); - - async function callResumeModel() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.resumeModel(request); - console.log(response); - } - - callResumeModel(); - // [END retail_v2_generated_ModelService_ResumeModel_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.tune_model.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.tune_model.js deleted file mode 100644 index cc82aa7db90..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.tune_model.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by 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_ModelService_TuneModel_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the model to tune. - * Format: - * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` - */ - // const name = 'abc123' - - // Imports the Retail library - const {ModelServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new ModelServiceClient(); - - async function callTuneModel() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await retailClient.tuneModel(request); - const [response] = await operation.promise(); - console.log(response); - } - - callTuneModel(); - // [END retail_v2_generated_ModelService_TuneModel_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.update_model.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.update_model.js deleted file mode 100644 index 2d7a2cbdb8c..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/model_service.update_model.js +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(model) { - // [START retail_v2_generated_ModelService_UpdateModel_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The body of the updated Model google.cloud.retail.v2.Model. - */ - // const model = {} - /** - * Optional. Indicates which fields in the provided 'model' to - * update. If not set, by default updates all fields. - */ - // const updateMask = {} - - // Imports the Retail library - const {ModelServiceClient} = require('@google-cloud/retail').v2; - - // Instantiates a client - const retailClient = new ModelServiceClient(); - - async function callUpdateModel() { - // Construct request - const request = { - model, - }; - - // Run request - const response = await retailClient.updateModel(request); - console.log(response); - } - - callUpdateModel(); - // [END retail_v2_generated_ModelService_UpdateModel_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/prediction_service.predict.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/prediction_service.predict.js deleted file mode 100644 index fffde01dc50..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/prediction_service.predict.js +++ /dev/null @@ -1,187 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of the format: - * `{placement=projects/* /locations/global/catalogs/default_catalog/servingConfigs/*}` - * or - * `{placement=projects/* /locations/global/catalogs/default_catalog/placements/*}`. - * We recommend using the `servingConfigs` resource. `placements` is a legacy - * resource. - * The ID of the Recommendations AI serving config or placement. - * Before you can request predictions from your model, you must create at - * least one serving config or placement for it. For more information, see - * Manage serving configs - * (https://cloud.google.com/retail/docs/manage-configs). - * The full list of available serving configs can be seen at - * https://console.cloud.google.com/ai/retail/catalogs/default_catalog/configs - */ - // 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. 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 - /** - * This field is not used; leave it unset. - */ - // 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 *no* - * results. If instead you want empty result sets to return generic - * (unfiltered) popular products, set `strictFiltering` to False in - * `PredictRequest.params`. Note that the API will never return items with - * storageStatus of "EXPIRED" or "DELETED" regardless of filter choices. - * If `filterSyntaxV2` is set to true under the `params` field, then - * attribute-based expressions are expected instead of the above described - * tag-based syntax. Examples: - * * (colors: ANY("Red", "Blue")) AND NOT (categories: ANY("Phones")) - * * (availability: ANY("IN_STOCK")) AND - * (colors: ANY("Red") OR categories: ANY("Phones")) - * For more information, see - * Filter recommendations (https://cloud.google.com/retail/docs/filter-recs). - */ - // 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 a 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. - * * `filterSyntaxV2`: Boolean. False by default. If set to true, the `filter` - * field is interpreteted according to the new, attribute-based syntax. - */ - // 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/google-cloud-retail/v2/samples/generated/v2/product_service.add_fulfillment_places.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.add_fulfillment_places.js deleted file mode 100644 index ecd9092bd27..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.add_fulfillment_places.js +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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.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/google-cloud-retail/v2/samples/generated/v2/product_service.add_local_inventories.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.add_local_inventories.js deleted file mode 100644 index 09806bed4c6..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.add_local_inventories.js +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2/samples/generated/v2/product_service.create_product.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.create_product.js deleted file mode 100644 index eb80e729016..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.create_product.js +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent 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/google-cloud-retail/v2/samples/generated/v2/product_service.delete_product.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.delete_product.js deleted file mode 100644 index 3f7f79b1469..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.delete_product.js +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2/samples/generated/v2/product_service.get_product.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.get_product.js deleted file mode 100644 index e70274c74cb..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.get_product.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2/samples/generated/v2/product_service.import_products.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.import_products.js deleted file mode 100644 index cfbac96515d..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.import_products.js +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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, all fields are updated. - */ - // 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 is sent to - * specified Pub/Sub topic. The message data is 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 `service-@gcp-sa-retail.iam.gserviceaccount.com` has the - * `pubsub.topics.publish` IAM permission on the topic. - */ - // 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/google-cloud-retail/v2/samples/generated/v2/product_service.list_products.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.list_products.js deleted file mode 100644 index 93dffde7845..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.list_products.js +++ /dev/null @@ -1,133 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent 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/google-cloud-retail/v2/samples/generated/v2/product_service.remove_fulfillment_places.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.remove_fulfillment_places.js deleted file mode 100644 index 036f23df698..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.remove_fulfillment_places.js +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2/samples/generated/v2/product_service.remove_local_inventories.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.remove_local_inventories.js deleted file mode 100644 index d553efef606..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.remove_local_inventories.js +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2/samples/generated/v2/product_service.set_inventory.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.set_inventory.js deleted file mode 100644 index 94d00a7ee35..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.set_inventory.js +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 google.cloud.retail.v2.Product.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 google.cloud.retail.v2.Product.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 google.cloud.retail.v2.Product.fulfillment_info - * * Checks that only the desired fulfillment info types have empty - * SetInventoryRequest.inventory.fulfillment_info.place_ids google.cloud.retail.v2.FulfillmentInfo.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, - * ProductService.UpdateProduct google.cloud.retail.v2.ProductService.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/google-cloud-retail/v2/samples/generated/v2/product_service.update_product.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.update_product.js deleted file mode 100644 index 4295a19c341..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/product_service.update_product.js +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The product 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/google-cloud-retail/v2/samples/generated/v2/search_service.search.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/search_service.search.js deleted file mode 100644 index be3c113ec07..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/search_service.search.js +++ /dev/null @@ -1,312 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the Retail Search serving config, such as - * `projects/* /locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` - * or the name of the legacy placement resource, such as - * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. - * This field is used to identify the serving config 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 200 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.v2.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, 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. - * Notice that if both - * ServingConfig.personalization_spec google.cloud.retail.v2.ServingConfig.personalization_spec - * and - * SearchRequest.personalization_spec google.cloud.retail.v2.SearchRequest.personalization_spec - * are set. - * SearchRequest.personalization_spec google.cloud.retail.v2.SearchRequest.personalization_spec - * will override - * ServingConfig.personalization_spec google.cloud.retail.v2.ServingConfig.personalization_spec. - */ - // 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 = {} - /** - * The entity for customers that may run multiple different entities, domains, - * sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, - * `google.com`, `youtube.com`, etc. - * If this is set, it should be exactly matched with - * UserEvent.entity google.cloud.retail.v2.UserEvent.entity to get search - * results boosted by entity. - */ - // const entity = 'abc123' - - // 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/google-cloud-retail/v2/samples/generated/v2/serving_config_service.add_control.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/serving_config_service.add_control.js deleted file mode 100644 index b6e99caa7c5..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/serving_config_service.add_control.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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_v2_generated_ServingConfigService_AddControl_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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').v2; - - // 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_v2_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/google-cloud-retail/v2/samples/generated/v2/serving_config_service.create_serving_config.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/serving_config_service.create_serving_config.js deleted file mode 100644 index 9fbf0d7e5b2..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/serving_config_service.create_serving_config.js +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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_v2_generated_ServingConfigService_CreateServingConfig_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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').v2; - - // 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_v2_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/google-cloud-retail/v2/samples/generated/v2/serving_config_service.delete_serving_config.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/serving_config_service.delete_serving_config.js deleted file mode 100644 index 7b947982621..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/serving_config_service.delete_serving_config.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by 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_ServingConfigService_DeleteServingConfig_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the 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').v2; - - // 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_v2_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/google-cloud-retail/v2/samples/generated/v2/serving_config_service.get_serving_config.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/serving_config_service.get_serving_config.js deleted file mode 100644 index 40c17c87fce..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/serving_config_service.get_serving_config.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by 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_ServingConfigService_GetServingConfig_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the 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').v2; - - // 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_v2_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/google-cloud-retail/v2/samples/generated/v2/serving_config_service.list_serving_configs.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/serving_config_service.list_serving_configs.js deleted file mode 100644 index 3393e11fe48..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/serving_config_service.list_serving_configs.js +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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_ServingConfigService_ListServingConfigs_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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').v2; - - // 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_v2_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/google-cloud-retail/v2/samples/generated/v2/serving_config_service.remove_control.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/serving_config_service.remove_control.js deleted file mode 100644 index bbcdb6f1caf..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/serving_config_service.remove_control.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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_v2_generated_ServingConfigService_RemoveControl_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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').v2; - - // 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_v2_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/google-cloud-retail/v2/samples/generated/v2/serving_config_service.update_serving_config.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/serving_config_service.update_serving_config.js deleted file mode 100644 index b4d671d1b98..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/serving_config_service.update_serving_config.js +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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_v2_generated_ServingConfigService_UpdateServingConfig_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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.v2.ServingConfig to update. The - * following are NOT supported: - * * ServingConfig.name google.cloud.retail.v2.ServingConfig.name - * If not set, all supported fields are updated. - */ - // const updateMask = {} - - // Imports the Retail library - const {ServingConfigServiceClient} = require('@google-cloud/retail').v2; - - // 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_v2_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/google-cloud-retail/v2/samples/generated/v2/snippet_metadata.google.cloud.retail.v2.json b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/snippet_metadata.google.cloud.retail.v2.json deleted file mode 100644 index 8a1372432b3..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/snippet_metadata.google.cloud.retail.v2.json +++ /dev/null @@ -1,2499 +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": 78, - "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": 65, - "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": 76, - "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": 53, - "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_CatalogService_GetCompletionConfig_async", - "title": "CatalogService getCompletionConfig Sample", - "origin": "API_DEFINITION", - "description": " Gets a [CompletionConfig][google.cloud.retail.v2.CompletionConfig].", - "canonical": true, - "file": "catalog_service.get_completion_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetCompletionConfig", - "fullName": "google.cloud.retail.v2.CatalogService.GetCompletionConfig", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2.CompletionConfig", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2.CatalogServiceClient" - }, - "method": { - "shortName": "GetCompletionConfig", - "fullName": "google.cloud.retail.v2.CatalogService.GetCompletionConfig", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_CatalogService_UpdateCompletionConfig_async", - "title": "CatalogService updateCompletionConfig Sample", - "origin": "API_DEFINITION", - "description": " Updates the [CompletionConfig][google.cloud.retail.v2.CompletionConfig]s.", - "canonical": true, - "file": "catalog_service.update_completion_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 70, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateCompletionConfig", - "fullName": "google.cloud.retail.v2.CatalogService.UpdateCompletionConfig", - "async": true, - "parameters": [ - { - "name": "completion_config", - "type": ".google.cloud.retail.v2.CompletionConfig" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.retail.v2.CompletionConfig", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2.CatalogServiceClient" - }, - "method": { - "shortName": "UpdateCompletionConfig", - "fullName": "google.cloud.retail.v2.CatalogService.UpdateCompletionConfig", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_CatalogService_GetAttributesConfig_async", - "title": "CatalogService getAttributesConfig Sample", - "origin": "API_DEFINITION", - "description": " Gets an [AttributesConfig][google.cloud.retail.v2.AttributesConfig].", - "canonical": true, - "file": "catalog_service.get_attributes_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetAttributesConfig", - "fullName": "google.cloud.retail.v2.CatalogService.GetAttributesConfig", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2.AttributesConfig", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2.CatalogServiceClient" - }, - "method": { - "shortName": "GetAttributesConfig", - "fullName": "google.cloud.retail.v2.CatalogService.GetAttributesConfig", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_CatalogService_UpdateAttributesConfig_async", - "title": "CatalogService updateAttributesConfig Sample", - "origin": "API_DEFINITION", - "description": " Updates the [AttributesConfig][google.cloud.retail.v2.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": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateAttributesConfig", - "fullName": "google.cloud.retail.v2.CatalogService.UpdateAttributesConfig", - "async": true, - "parameters": [ - { - "name": "attributes_config", - "type": ".google.cloud.retail.v2.AttributesConfig" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.retail.v2.AttributesConfig", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2.CatalogServiceClient" - }, - "method": { - "shortName": "UpdateAttributesConfig", - "fullName": "google.cloud.retail.v2.CatalogService.UpdateAttributesConfig", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_CatalogService_AddCatalogAttribute_async", - "title": "CatalogService addCatalogAttribute Sample", - "origin": "API_DEFINITION", - "description": " Adds the specified [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] to the [AttributesConfig][google.cloud.retail.v2.AttributesConfig]. If the [CatalogAttribute][google.cloud.retail.v2.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": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AddCatalogAttribute", - "fullName": "google.cloud.retail.v2.CatalogService.AddCatalogAttribute", - "async": true, - "parameters": [ - { - "name": "attributes_config", - "type": "TYPE_STRING" - }, - { - "name": "catalog_attribute", - "type": ".google.cloud.retail.v2.CatalogAttribute" - } - ], - "resultType": ".google.cloud.retail.v2.AttributesConfig", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2.CatalogServiceClient" - }, - "method": { - "shortName": "AddCatalogAttribute", - "fullName": "google.cloud.retail.v2.CatalogService.AddCatalogAttribute", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_CatalogService_RemoveCatalogAttribute_async", - "title": "CatalogService removeCatalogAttribute Sample", - "origin": "API_DEFINITION", - "description": " Removes the specified [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] from the [AttributesConfig][google.cloud.retail.v2.AttributesConfig]. If the [CatalogAttribute][google.cloud.retail.v2.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": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RemoveCatalogAttribute", - "fullName": "google.cloud.retail.v2.CatalogService.RemoveCatalogAttribute", - "async": true, - "parameters": [ - { - "name": "attributes_config", - "type": "TYPE_STRING" - }, - { - "name": "key", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2.AttributesConfig", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2.CatalogServiceClient" - }, - "method": { - "shortName": "RemoveCatalogAttribute", - "fullName": "google.cloud.retail.v2.CatalogService.RemoveCatalogAttribute", - "service": { - "shortName": "CatalogService", - "fullName": "google.cloud.retail.v2.CatalogService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_CatalogService_ReplaceCatalogAttribute_async", - "title": "CatalogService replaceCatalogAttribute Sample", - "origin": "API_DEFINITION", - "description": " Replaces the specified [CatalogAttribute][google.cloud.retail.v2.CatalogAttribute] in the [AttributesConfig][google.cloud.retail.v2.AttributesConfig] by updating the catalog attribute with the same [CatalogAttribute.key][google.cloud.retail.v2.CatalogAttribute.key]. If the [CatalogAttribute][google.cloud.retail.v2.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": 68, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ReplaceCatalogAttribute", - "fullName": "google.cloud.retail.v2.CatalogService.ReplaceCatalogAttribute", - "async": true, - "parameters": [ - { - "name": "attributes_config", - "type": "TYPE_STRING" - }, - { - "name": "catalog_attribute", - "type": ".google.cloud.retail.v2.CatalogAttribute" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.retail.v2.AttributesConfig", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2.CatalogServiceClient" - }, - "method": { - "shortName": "ReplaceCatalogAttribute", - "fullName": "google.cloud.retail.v2.CatalogService.ReplaceCatalogAttribute", - "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. Enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "completion_service.complete_query.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 124, - "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" - }, - { - "name": "entity", - "type": "TYPE_STRING" - } - ], - "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. 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": 68, - "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_ControlService_CreateControl_async", - "title": "CatalogService createControl Sample", - "origin": "API_DEFINITION", - "description": " Creates a Control. If the [Control][google.cloud.retail.v2.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": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateControl", - "fullName": "google.cloud.retail.v2.ControlService.CreateControl", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "control", - "type": ".google.cloud.retail.v2.Control" - }, - { - "name": "control_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2.Control", - "client": { - "shortName": "ControlServiceClient", - "fullName": "google.cloud.retail.v2.ControlServiceClient" - }, - "method": { - "shortName": "CreateControl", - "fullName": "google.cloud.retail.v2.ControlService.CreateControl", - "service": { - "shortName": "ControlService", - "fullName": "google.cloud.retail.v2.ControlService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_ControlService_DeleteControl_async", - "title": "CatalogService deleteControl Sample", - "origin": "API_DEFINITION", - "description": " Deletes a Control. If the [Control][google.cloud.retail.v2.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": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteControl", - "fullName": "google.cloud.retail.v2.ControlService.DeleteControl", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ControlServiceClient", - "fullName": "google.cloud.retail.v2.ControlServiceClient" - }, - "method": { - "shortName": "DeleteControl", - "fullName": "google.cloud.retail.v2.ControlService.DeleteControl", - "service": { - "shortName": "ControlService", - "fullName": "google.cloud.retail.v2.ControlService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_ControlService_UpdateControl_async", - "title": "CatalogService updateControl Sample", - "origin": "API_DEFINITION", - "description": " Updates a Control. [Control][google.cloud.retail.v2.Control] cannot be set to a different oneof field, if so an INVALID_ARGUMENT is returned. If the [Control][google.cloud.retail.v2.Control] to update does not exist, a NOT_FOUND error is returned.", - "canonical": true, - "file": "control_service.update_control.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 61, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateControl", - "fullName": "google.cloud.retail.v2.ControlService.UpdateControl", - "async": true, - "parameters": [ - { - "name": "control", - "type": ".google.cloud.retail.v2.Control" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.retail.v2.Control", - "client": { - "shortName": "ControlServiceClient", - "fullName": "google.cloud.retail.v2.ControlServiceClient" - }, - "method": { - "shortName": "UpdateControl", - "fullName": "google.cloud.retail.v2.ControlService.UpdateControl", - "service": { - "shortName": "ControlService", - "fullName": "google.cloud.retail.v2.ControlService" - } - } - } - }, - { - "regionTag": "retail_v2_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": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetControl", - "fullName": "google.cloud.retail.v2.ControlService.GetControl", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2.Control", - "client": { - "shortName": "ControlServiceClient", - "fullName": "google.cloud.retail.v2.ControlServiceClient" - }, - "method": { - "shortName": "GetControl", - "fullName": "google.cloud.retail.v2.ControlService.GetControl", - "service": { - "shortName": "ControlService", - "fullName": "google.cloud.retail.v2.ControlService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_ControlService_ListControls_async", - "title": "CatalogService listControls Sample", - "origin": "API_DEFINITION", - "description": " Lists all Controls by their parent [Catalog][google.cloud.retail.v2.Catalog].", - "canonical": true, - "file": "control_service.list_controls.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 74, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListControls", - "fullName": "google.cloud.retail.v2.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.v2.ListControlsResponse", - "client": { - "shortName": "ControlServiceClient", - "fullName": "google.cloud.retail.v2.ControlServiceClient" - }, - "method": { - "shortName": "ListControls", - "fullName": "google.cloud.retail.v2.ControlService.ListControls", - "service": { - "shortName": "ControlService", - "fullName": "google.cloud.retail.v2.ControlService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_ModelService_CreateModel_async", - "title": "CatalogService createModel Sample", - "origin": "API_DEFINITION", - "description": " Creates a new model.", - "canonical": true, - "file": "model_service.create_model.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateModel", - "fullName": "google.cloud.retail.v2.ModelService.CreateModel", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "model", - "type": ".google.cloud.retail.v2.Model" - }, - { - "name": "dry_run", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ModelServiceClient", - "fullName": "google.cloud.retail.v2.ModelServiceClient" - }, - "method": { - "shortName": "CreateModel", - "fullName": "google.cloud.retail.v2.ModelService.CreateModel", - "service": { - "shortName": "ModelService", - "fullName": "google.cloud.retail.v2.ModelService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_ModelService_GetModel_async", - "title": "CatalogService getModel Sample", - "origin": "API_DEFINITION", - "description": " Gets a model.", - "canonical": true, - "file": "model_service.get_model.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetModel", - "fullName": "google.cloud.retail.v2.ModelService.GetModel", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2.Model", - "client": { - "shortName": "ModelServiceClient", - "fullName": "google.cloud.retail.v2.ModelServiceClient" - }, - "method": { - "shortName": "GetModel", - "fullName": "google.cloud.retail.v2.ModelService.GetModel", - "service": { - "shortName": "ModelService", - "fullName": "google.cloud.retail.v2.ModelService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_ModelService_PauseModel_async", - "title": "CatalogService pauseModel Sample", - "origin": "API_DEFINITION", - "description": " Pauses the training of an existing model.", - "canonical": true, - "file": "model_service.pause_model.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "PauseModel", - "fullName": "google.cloud.retail.v2.ModelService.PauseModel", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2.Model", - "client": { - "shortName": "ModelServiceClient", - "fullName": "google.cloud.retail.v2.ModelServiceClient" - }, - "method": { - "shortName": "PauseModel", - "fullName": "google.cloud.retail.v2.ModelService.PauseModel", - "service": { - "shortName": "ModelService", - "fullName": "google.cloud.retail.v2.ModelService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_ModelService_ResumeModel_async", - "title": "CatalogService resumeModel Sample", - "origin": "API_DEFINITION", - "description": " Resumes the training of an existing model.", - "canonical": true, - "file": "model_service.resume_model.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ResumeModel", - "fullName": "google.cloud.retail.v2.ModelService.ResumeModel", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2.Model", - "client": { - "shortName": "ModelServiceClient", - "fullName": "google.cloud.retail.v2.ModelServiceClient" - }, - "method": { - "shortName": "ResumeModel", - "fullName": "google.cloud.retail.v2.ModelService.ResumeModel", - "service": { - "shortName": "ModelService", - "fullName": "google.cloud.retail.v2.ModelService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_ModelService_DeleteModel_async", - "title": "CatalogService deleteModel Sample", - "origin": "API_DEFINITION", - "description": " Deletes an existing model.", - "canonical": true, - "file": "model_service.delete_model.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteModel", - "fullName": "google.cloud.retail.v2.ModelService.DeleteModel", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ModelServiceClient", - "fullName": "google.cloud.retail.v2.ModelServiceClient" - }, - "method": { - "shortName": "DeleteModel", - "fullName": "google.cloud.retail.v2.ModelService.DeleteModel", - "service": { - "shortName": "ModelService", - "fullName": "google.cloud.retail.v2.ModelService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_ModelService_ListModels_async", - "title": "CatalogService listModels Sample", - "origin": "API_DEFINITION", - "description": " Lists all the models linked to this event store.", - "canonical": true, - "file": "model_service.list_models.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListModels", - "fullName": "google.cloud.retail.v2.ModelService.ListModels", - "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.ListModelsResponse", - "client": { - "shortName": "ModelServiceClient", - "fullName": "google.cloud.retail.v2.ModelServiceClient" - }, - "method": { - "shortName": "ListModels", - "fullName": "google.cloud.retail.v2.ModelService.ListModels", - "service": { - "shortName": "ModelService", - "fullName": "google.cloud.retail.v2.ModelService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_ModelService_UpdateModel_async", - "title": "CatalogService updateModel Sample", - "origin": "API_DEFINITION", - "description": " Update of model metadata. Only fields that currently can be updated are: `filtering_option` and `periodic_tuning_state`. If other values are provided, this API method ignores them.", - "canonical": true, - "file": "model_service.update_model.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 58, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateModel", - "fullName": "google.cloud.retail.v2.ModelService.UpdateModel", - "async": true, - "parameters": [ - { - "name": "model", - "type": ".google.cloud.retail.v2.Model" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.retail.v2.Model", - "client": { - "shortName": "ModelServiceClient", - "fullName": "google.cloud.retail.v2.ModelServiceClient" - }, - "method": { - "shortName": "UpdateModel", - "fullName": "google.cloud.retail.v2.ModelService.UpdateModel", - "service": { - "shortName": "ModelService", - "fullName": "google.cloud.retail.v2.ModelService" - } - } - } - }, - { - "regionTag": "retail_v2_generated_ModelService_TuneModel_async", - "title": "CatalogService tuneModel Sample", - "origin": "API_DEFINITION", - "description": " Tunes an existing model.", - "canonical": true, - "file": "model_service.tune_model.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 56, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "TuneModel", - "fullName": "google.cloud.retail.v2.ModelService.TuneModel", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ModelServiceClient", - "fullName": "google.cloud.retail.v2.ModelServiceClient" - }, - "method": { - "shortName": "TuneModel", - "fullName": "google.cloud.retail.v2.ModelService.TuneModel", - "service": { - "shortName": "ModelService", - "fullName": "google.cloud.retail.v2.ModelService" - } - } - } - }, - { - "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": 179, - "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": 75, - "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": 60, - "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": 125, - "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": 79, - "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": 69, - "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": 90, - "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 is 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 [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. When inventory is updated with [ProductService.CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] and [ProductService.UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct], the specified inventory field value(s) overwrite any existing value(s) while ignoring the last update time for this field. Furthermore, the last update times for the specified inventory fields are overwritten by the times of the [ProductService.CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] or [ProductService.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 is used. If no inventory fields are set in [SetInventoryRequest.set_mask][google.cloud.retail.v2.SetInventoryRequest.set_mask], then any existing inventory information is preserved. Pre-existing inventory information can only be updated with [ProductService.SetInventory][google.cloud.retail.v2.ProductService.SetInventory], [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2.ProductService.AddFulfillmentPlaces], and [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces]. The returned [Operation][google.longrunning.Operation]s is obsolete after one day, and the [GetOperation][google.longrunning.Operations.GetOperation] API returns `NOT_FOUND` afterwards. If conflicting updates are issued, the [Operation][google.longrunning.Operation]s associated with the stale updates are not marked as [done][google.longrunning.Operation.done] until they are obsolete.", - "canonical": true, - "file": "product_service.set_inventory.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 123, - "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": " It is recommended to use the [ProductService.AddLocalInventories][google.cloud.retail.v2.ProductService.AddLocalInventories] method instead of [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2.ProductService.AddFulfillmentPlaces]. [ProductService.AddLocalInventories][google.cloud.retail.v2.ProductService.AddLocalInventories] achieves the same results but provides more fine-grained control over ingesting local inventory data. 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 [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. The returned [Operation][google.longrunning.Operation]s will be obsolete after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] API will return NOT_FOUND afterwards. If conflicting updates are issued, the [Operation][google.longrunning.Operation]s associated with the stale updates will not be marked as [done][google.longrunning.Operation.done] until being obsolete.", - "canonical": true, - "file": "product_service.add_fulfillment_places.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 111, - "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": " It is recommended to use the [ProductService.RemoveLocalInventories][google.cloud.retail.v2.ProductService.RemoveLocalInventories] method instead of [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces]. [ProductService.RemoveLocalInventories][google.cloud.retail.v2.ProductService.RemoveLocalInventories] achieves the same results but provides more fine-grained control over ingesting local inventory data. 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 [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. The returned [Operation][google.longrunning.Operation]s will be obsolete after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] API will return NOT_FOUND afterwards. If conflicting updates are issued, the [Operation][google.longrunning.Operation]s associated with the stale updates will not be marked as [done][google.longrunning.Operation.done] until being obsolete.", - "canonical": true, - "file": "product_service.remove_fulfillment_places.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 107, - "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 [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. Local inventory information can only be modified using this method. [ProductService.CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] and [ProductService.UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] has no effect on local inventories. The returned [Operation][google.longrunning.Operation]s will be obsolete after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] API will return NOT_FOUND afterwards. If conflicting updates are issued, the [Operation][google.longrunning.Operation]s associated with the stale updates will not be marked as [done][google.longrunning.Operation.done] until being obsolete.", - "canonical": true, - "file": "product_service.add_local_inventories.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 94, - "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 [ProductService.GetProduct][google.cloud.retail.v2.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2.ProductService.ListProducts]. Local inventory information can only be removed using this method. [ProductService.CreateProduct][google.cloud.retail.v2.ProductService.CreateProduct] and [ProductService.UpdateProduct][google.cloud.retail.v2.ProductService.UpdateProduct] has no effect on local inventories. The returned [Operation][google.longrunning.Operation]s will be obsolete after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] API will return NOT_FOUND afterwards. If conflicting updates are issued, the [Operation][google.longrunning.Operation]s associated with the stale updates will not be marked as [done][google.longrunning.Operation.done] until being obsolete.", - "canonical": true, - "file": "product_service.remove_local_inventories.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 80, - "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. Enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "search_service.search.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 304, - "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" - }, - { - "name": "entity", - "type": "TYPE_STRING" - } - ], - "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_ServingConfigService_CreateServingConfig_async", - "title": "CatalogService createServingConfig Sample", - "origin": "API_DEFINITION", - "description": " Creates a ServingConfig. A maximum of 100 [ServingConfig][google.cloud.retail.v2.ServingConfig]s are allowed in a [Catalog][google.cloud.retail.v2.Catalog], otherwise a FAILED_PRECONDITION error is returned.", - "canonical": true, - "file": "serving_config_service.create_serving_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateServingConfig", - "fullName": "google.cloud.retail.v2.ServingConfigService.CreateServingConfig", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "serving_config", - "type": ".google.cloud.retail.v2.ServingConfig" - }, - { - "name": "serving_config_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2.ServingConfig", - "client": { - "shortName": "ServingConfigServiceClient", - "fullName": "google.cloud.retail.v2.ServingConfigServiceClient" - }, - "method": { - "shortName": "CreateServingConfig", - "fullName": "google.cloud.retail.v2.ServingConfigService.CreateServingConfig", - "service": { - "shortName": "ServingConfigService", - "fullName": "google.cloud.retail.v2.ServingConfigService" - } - } - } - }, - { - "regionTag": "retail_v2_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": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteServingConfig", - "fullName": "google.cloud.retail.v2.ServingConfigService.DeleteServingConfig", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ServingConfigServiceClient", - "fullName": "google.cloud.retail.v2.ServingConfigServiceClient" - }, - "method": { - "shortName": "DeleteServingConfig", - "fullName": "google.cloud.retail.v2.ServingConfigService.DeleteServingConfig", - "service": { - "shortName": "ServingConfigService", - "fullName": "google.cloud.retail.v2.ServingConfigService" - } - } - } - }, - { - "regionTag": "retail_v2_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": 61, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateServingConfig", - "fullName": "google.cloud.retail.v2.ServingConfigService.UpdateServingConfig", - "async": true, - "parameters": [ - { - "name": "serving_config", - "type": ".google.cloud.retail.v2.ServingConfig" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.retail.v2.ServingConfig", - "client": { - "shortName": "ServingConfigServiceClient", - "fullName": "google.cloud.retail.v2.ServingConfigServiceClient" - }, - "method": { - "shortName": "UpdateServingConfig", - "fullName": "google.cloud.retail.v2.ServingConfigService.UpdateServingConfig", - "service": { - "shortName": "ServingConfigService", - "fullName": "google.cloud.retail.v2.ServingConfigService" - } - } - } - }, - { - "regionTag": "retail_v2_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": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetServingConfig", - "fullName": "google.cloud.retail.v2.ServingConfigService.GetServingConfig", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2.ServingConfig", - "client": { - "shortName": "ServingConfigServiceClient", - "fullName": "google.cloud.retail.v2.ServingConfigServiceClient" - }, - "method": { - "shortName": "GetServingConfig", - "fullName": "google.cloud.retail.v2.ServingConfigService.GetServingConfig", - "service": { - "shortName": "ServingConfigService", - "fullName": "google.cloud.retail.v2.ServingConfigService" - } - } - } - }, - { - "regionTag": "retail_v2_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": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListServingConfigs", - "fullName": "google.cloud.retail.v2.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.v2.ListServingConfigsResponse", - "client": { - "shortName": "ServingConfigServiceClient", - "fullName": "google.cloud.retail.v2.ServingConfigServiceClient" - }, - "method": { - "shortName": "ListServingConfigs", - "fullName": "google.cloud.retail.v2.ServingConfigService.ListServingConfigs", - "service": { - "shortName": "ServingConfigService", - "fullName": "google.cloud.retail.v2.ServingConfigService" - } - } - } - }, - { - "regionTag": "retail_v2_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": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "AddControl", - "fullName": "google.cloud.retail.v2.ServingConfigService.AddControl", - "async": true, - "parameters": [ - { - "name": "serving_config", - "type": "TYPE_STRING" - }, - { - "name": "control_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2.ServingConfig", - "client": { - "shortName": "ServingConfigServiceClient", - "fullName": "google.cloud.retail.v2.ServingConfigServiceClient" - }, - "method": { - "shortName": "AddControl", - "fullName": "google.cloud.retail.v2.ServingConfigService.AddControl", - "service": { - "shortName": "ServingConfigService", - "fullName": "google.cloud.retail.v2.ServingConfigService" - } - } - } - }, - { - "regionTag": "retail_v2_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": 60, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "RemoveControl", - "fullName": "google.cloud.retail.v2.ServingConfigService.RemoveControl", - "async": true, - "parameters": [ - { - "name": "serving_config", - "type": "TYPE_STRING" - }, - { - "name": "control_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2.ServingConfig", - "client": { - "shortName": "ServingConfigServiceClient", - "fullName": "google.cloud.retail.v2.ServingConfigServiceClient" - }, - "method": { - "shortName": "RemoveControl", - "fullName": "google.cloud.retail.v2.ServingConfigService.RemoveControl", - "service": { - "shortName": "ServingConfigService", - "fullName": "google.cloud.retail.v2.ServingConfigService" - } - } - } - }, - { - "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": 66, - "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" - }, - { - "name": "write_async", - "type": "TYPE_BOOL" - } - ], - "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": 85, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CollectUserEvent", - "fullName": "google.cloud.retail.v2.UserEventService.CollectUserEvent", - "async": true, - "parameters": [ - { - "name": "prebuilt_rule", - "type": "TYPE_STRING" - }, - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "user_event", - "type": "TYPE_STRING" - }, - { - "name": "uri", - "type": "TYPE_STRING" - }, - { - "name": "ets", - "type": "TYPE_INT64" - }, - { - "name": "raw_json", - "type": "TYPE_STRING" - } - ], - "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": 85, - "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": 64, - "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 are not annotated with detailed product information for products that are missing from the catalog when the user event is ingested. These events are stored as unjoined events with limited usage on training and serving. You can use this method to start a join operation on specified events with the latest version of product catalog. You can also use this method 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": 62, - "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/google-cloud-retail/v2/samples/generated/v2/user_event_service.collect_user_event.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/user_event_service.collect_user_event.js deleted file mode 100644 index 9e37dc26a8d..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/user_event_service.collect_user_event.js +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * The prebuilt rule name that can convert a specific type of raw_json. - * For example: "ga4_bq" rule for the GA4 user event schema. - */ - // const prebuiltRule = 'abc123' - /** - * 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 - /** - * An arbitrary serialized JSON string that contains necessary information - * that can comprise a user event. When this field is specified, the - * user_event field will be ignored. Note: line-delimited JSON is not - * supported, a single JSON only. - */ - // const rawJson = 'abc123' - - // 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/google-cloud-retail/v2/samples/generated/v2/user_event_service.import_user_events.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/user_event_service.import_user_events.js deleted file mode 100644 index f7410fdd4f3..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/user_event_service.import_user_events.js +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2/samples/generated/v2/user_event_service.purge_user_events.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/user_event_service.purge_user_events.js deleted file mode 100644 index b96b3fdd6e8..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/user_event_service.purge_user_events.js +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the 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/google-cloud-retail/v2/samples/generated/v2/user_event_service.rejoin_user_events.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/user_event_service.rejoin_user_events.js deleted file mode 100644 index ac4e6ad1e23..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/user_event_service.rejoin_user_events.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent 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/google-cloud-retail/v2/samples/generated/v2/user_event_service.write_user_event.js b/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/user_event_service.write_user_event.js deleted file mode 100644 index b71384d22e8..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/samples/generated/v2/user_event_service.write_user_event.js +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent catalog resource name, such as - * `projects/1234/locations/global/catalogs/default_catalog`. - */ - // const parent = 'abc123' - /** - * Required. User event to write. - */ - // const userEvent = {} - /** - * If set to true, the user event will be written asynchronously after - * validation, and the API will respond without waiting for the write. - * Therefore, silent failures can occur even if the API returns success. In - * case of silent failures, error messages can be found in Stackdriver logs. - */ - // const writeAsync = true - - // 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/google-cloud-retail/v2/src/index.ts b/owl-bot-staging/google-cloud-retail/v2/src/index.ts deleted file mode 100644 index 326bdd05f98..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/src/index.ts +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This 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 ControlServiceClient = v2.ControlServiceClient; -type ControlServiceClient = v2.ControlServiceClient; -const ModelServiceClient = v2.ModelServiceClient; -type ModelServiceClient = v2.ModelServiceClient; -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 ServingConfigServiceClient = v2.ServingConfigServiceClient; -type ServingConfigServiceClient = v2.ServingConfigServiceClient; -const UserEventServiceClient = v2.UserEventServiceClient; -type UserEventServiceClient = v2.UserEventServiceClient; -export {v2, CatalogServiceClient, CompletionServiceClient, ControlServiceClient, ModelServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, ServingConfigServiceClient, UserEventServiceClient}; -export default {v2, CatalogServiceClient, CompletionServiceClient, ControlServiceClient, ModelServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, ServingConfigServiceClient, UserEventServiceClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-retail/v2/src/v2/catalog_service_client.ts b/owl-bot-staging/google-cloud-retail/v2/src/v2/catalog_service_client.ts deleted file mode 100644 index 1d0d40dc106..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/src/v2/catalog_service_client.ts +++ /dev/null @@ -1,2223 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/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}; - locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - 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/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new CatalogServiceClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof 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); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - this.locationsClient = new this._gaxModule.LocationsClient( - this._gaxGrpc, - opts - ); - - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - 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}' - ), - modelPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' - ), - 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') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2/{name=projects/*/locations/*/operations/*}',additional_bindings: [{get: '/v2/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',},{get: '/v2/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2/{name=projects/*/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2/{name=projects/*/locations/*}/operations',additional_bindings: [{get: '/v2/{name=projects/*/locations/*/catalogs/*}/operations',},{get: '/v2/{name=projects/*}/operations',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - - this.descriptors.longrunning = { - }; - - // 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 = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.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', '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._opts.fallback - ); - - 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 {@link google.cloud.retail.v2.Catalog | 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' - ] = this._gaxModule.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 {@link google.protobuf.Empty | 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' - ] = this._gaxModule.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 {@link google.cloud.retail.v2.GetDefaultBranchResponse | 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'catalog': request.catalog ?? '', - }); - this.initialize(); - return this.innerApiCalls.getDefaultBranch(request, options, callback); - } -/** - * Gets a {@link google.cloud.retail.v2.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 {@link google.cloud.retail.v2.CompletionConfig | 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/v2/catalog_service.get_completion_config.js - * region_tag:retail_v2_generated_CatalogService_GetCompletionConfig_async - */ - getCompletionConfig( - request?: protos.google.cloud.retail.v2.IGetCompletionConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2.ICompletionConfig, - protos.google.cloud.retail.v2.IGetCompletionConfigRequest|undefined, {}|undefined - ]>; - getCompletionConfig( - request: protos.google.cloud.retail.v2.IGetCompletionConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2.ICompletionConfig, - protos.google.cloud.retail.v2.IGetCompletionConfigRequest|null|undefined, - {}|null|undefined>): void; - getCompletionConfig( - request: protos.google.cloud.retail.v2.IGetCompletionConfigRequest, - callback: Callback< - protos.google.cloud.retail.v2.ICompletionConfig, - protos.google.cloud.retail.v2.IGetCompletionConfigRequest|null|undefined, - {}|null|undefined>): void; - getCompletionConfig( - request?: protos.google.cloud.retail.v2.IGetCompletionConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2.ICompletionConfig, - protos.google.cloud.retail.v2.IGetCompletionConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2.ICompletionConfig, - protos.google.cloud.retail.v2.IGetCompletionConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2.ICompletionConfig, - protos.google.cloud.retail.v2.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' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getCompletionConfig(request, options, callback); - } -/** - * Updates the {@link google.cloud.retail.v2.CompletionConfig|CompletionConfig}s. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.retail.v2.CompletionConfig} request.completionConfig - * Required. The {@link google.cloud.retail.v2.CompletionConfig|CompletionConfig} - * to update. - * - * If the caller does not have permission to update the - * {@link google.cloud.retail.v2.CompletionConfig|CompletionConfig}, then a - * PERMISSION_DENIED error is returned. - * - * If the {@link google.cloud.retail.v2.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.v2.CompletionConfig|CompletionConfig} to update. The - * following are the only supported fields: - * - * * {@link google.cloud.retail.v2.CompletionConfig.matching_order|CompletionConfig.matching_order} - * * {@link google.cloud.retail.v2.CompletionConfig.max_suggestions|CompletionConfig.max_suggestions} - * * {@link google.cloud.retail.v2.CompletionConfig.min_prefix_length|CompletionConfig.min_prefix_length} - * * {@link google.cloud.retail.v2.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 {@link google.cloud.retail.v2.CompletionConfig | 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/v2/catalog_service.update_completion_config.js - * region_tag:retail_v2_generated_CatalogService_UpdateCompletionConfig_async - */ - updateCompletionConfig( - request?: protos.google.cloud.retail.v2.IUpdateCompletionConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2.ICompletionConfig, - protos.google.cloud.retail.v2.IUpdateCompletionConfigRequest|undefined, {}|undefined - ]>; - updateCompletionConfig( - request: protos.google.cloud.retail.v2.IUpdateCompletionConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2.ICompletionConfig, - protos.google.cloud.retail.v2.IUpdateCompletionConfigRequest|null|undefined, - {}|null|undefined>): void; - updateCompletionConfig( - request: protos.google.cloud.retail.v2.IUpdateCompletionConfigRequest, - callback: Callback< - protos.google.cloud.retail.v2.ICompletionConfig, - protos.google.cloud.retail.v2.IUpdateCompletionConfigRequest|null|undefined, - {}|null|undefined>): void; - updateCompletionConfig( - request?: protos.google.cloud.retail.v2.IUpdateCompletionConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2.ICompletionConfig, - protos.google.cloud.retail.v2.IUpdateCompletionConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2.ICompletionConfig, - protos.google.cloud.retail.v2.IUpdateCompletionConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2.ICompletionConfig, - protos.google.cloud.retail.v2.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' - ] = this._gaxModule.routingHeader.fromParams({ - 'completion_config.name': request.completionConfig!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateCompletionConfig(request, options, callback); - } -/** - * Gets an {@link google.cloud.retail.v2.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 {@link google.cloud.retail.v2.AttributesConfig | 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/v2/catalog_service.get_attributes_config.js - * region_tag:retail_v2_generated_CatalogService_GetAttributesConfig_async - */ - getAttributesConfig( - request?: protos.google.cloud.retail.v2.IGetAttributesConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2.IAttributesConfig, - protos.google.cloud.retail.v2.IGetAttributesConfigRequest|undefined, {}|undefined - ]>; - getAttributesConfig( - request: protos.google.cloud.retail.v2.IGetAttributesConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2.IAttributesConfig, - protos.google.cloud.retail.v2.IGetAttributesConfigRequest|null|undefined, - {}|null|undefined>): void; - getAttributesConfig( - request: protos.google.cloud.retail.v2.IGetAttributesConfigRequest, - callback: Callback< - protos.google.cloud.retail.v2.IAttributesConfig, - protos.google.cloud.retail.v2.IGetAttributesConfigRequest|null|undefined, - {}|null|undefined>): void; - getAttributesConfig( - request?: protos.google.cloud.retail.v2.IGetAttributesConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2.IAttributesConfig, - protos.google.cloud.retail.v2.IGetAttributesConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2.IAttributesConfig, - protos.google.cloud.retail.v2.IGetAttributesConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2.IAttributesConfig, - protos.google.cloud.retail.v2.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' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getAttributesConfig(request, options, callback); - } -/** - * Updates the {@link google.cloud.retail.v2.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.v2.AttributesConfig} request.attributesConfig - * Required. The {@link google.cloud.retail.v2.AttributesConfig|AttributesConfig} - * to update. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided - * {@link google.cloud.retail.v2.AttributesConfig|AttributesConfig} to update. The - * following is the only supported field: - * - * * {@link google.cloud.retail.v2.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 {@link google.cloud.retail.v2.AttributesConfig | 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/v2/catalog_service.update_attributes_config.js - * region_tag:retail_v2_generated_CatalogService_UpdateAttributesConfig_async - */ - updateAttributesConfig( - request?: protos.google.cloud.retail.v2.IUpdateAttributesConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2.IAttributesConfig, - protos.google.cloud.retail.v2.IUpdateAttributesConfigRequest|undefined, {}|undefined - ]>; - updateAttributesConfig( - request: protos.google.cloud.retail.v2.IUpdateAttributesConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2.IAttributesConfig, - protos.google.cloud.retail.v2.IUpdateAttributesConfigRequest|null|undefined, - {}|null|undefined>): void; - updateAttributesConfig( - request: protos.google.cloud.retail.v2.IUpdateAttributesConfigRequest, - callback: Callback< - protos.google.cloud.retail.v2.IAttributesConfig, - protos.google.cloud.retail.v2.IUpdateAttributesConfigRequest|null|undefined, - {}|null|undefined>): void; - updateAttributesConfig( - request?: protos.google.cloud.retail.v2.IUpdateAttributesConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2.IAttributesConfig, - protos.google.cloud.retail.v2.IUpdateAttributesConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2.IAttributesConfig, - protos.google.cloud.retail.v2.IUpdateAttributesConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2.IAttributesConfig, - protos.google.cloud.retail.v2.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' - ] = this._gaxModule.routingHeader.fromParams({ - 'attributes_config.name': request.attributesConfig!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateAttributesConfig(request, options, callback); - } -/** - * Adds the specified - * {@link google.cloud.retail.v2.CatalogAttribute|CatalogAttribute} to the - * {@link google.cloud.retail.v2.AttributesConfig|AttributesConfig}. - * - * If the {@link google.cloud.retail.v2.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.v2.CatalogAttribute} request.catalogAttribute - * Required. The {@link google.cloud.retail.v2.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 {@link google.cloud.retail.v2.AttributesConfig | 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/v2/catalog_service.add_catalog_attribute.js - * region_tag:retail_v2_generated_CatalogService_AddCatalogAttribute_async - */ - addCatalogAttribute( - request?: protos.google.cloud.retail.v2.IAddCatalogAttributeRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2.IAttributesConfig, - protos.google.cloud.retail.v2.IAddCatalogAttributeRequest|undefined, {}|undefined - ]>; - addCatalogAttribute( - request: protos.google.cloud.retail.v2.IAddCatalogAttributeRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2.IAttributesConfig, - protos.google.cloud.retail.v2.IAddCatalogAttributeRequest|null|undefined, - {}|null|undefined>): void; - addCatalogAttribute( - request: protos.google.cloud.retail.v2.IAddCatalogAttributeRequest, - callback: Callback< - protos.google.cloud.retail.v2.IAttributesConfig, - protos.google.cloud.retail.v2.IAddCatalogAttributeRequest|null|undefined, - {}|null|undefined>): void; - addCatalogAttribute( - request?: protos.google.cloud.retail.v2.IAddCatalogAttributeRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2.IAttributesConfig, - protos.google.cloud.retail.v2.IAddCatalogAttributeRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2.IAttributesConfig, - protos.google.cloud.retail.v2.IAddCatalogAttributeRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2.IAttributesConfig, - protos.google.cloud.retail.v2.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' - ] = this._gaxModule.routingHeader.fromParams({ - 'attributes_config': request.attributesConfig ?? '', - }); - this.initialize(); - return this.innerApiCalls.addCatalogAttribute(request, options, callback); - } -/** - * Removes the specified - * {@link google.cloud.retail.v2.CatalogAttribute|CatalogAttribute} from the - * {@link google.cloud.retail.v2.AttributesConfig|AttributesConfig}. - * - * If the {@link google.cloud.retail.v2.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.v2.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 {@link google.cloud.retail.v2.AttributesConfig | 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/v2/catalog_service.remove_catalog_attribute.js - * region_tag:retail_v2_generated_CatalogService_RemoveCatalogAttribute_async - */ - removeCatalogAttribute( - request?: protos.google.cloud.retail.v2.IRemoveCatalogAttributeRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2.IAttributesConfig, - protos.google.cloud.retail.v2.IRemoveCatalogAttributeRequest|undefined, {}|undefined - ]>; - removeCatalogAttribute( - request: protos.google.cloud.retail.v2.IRemoveCatalogAttributeRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2.IAttributesConfig, - protos.google.cloud.retail.v2.IRemoveCatalogAttributeRequest|null|undefined, - {}|null|undefined>): void; - removeCatalogAttribute( - request: protos.google.cloud.retail.v2.IRemoveCatalogAttributeRequest, - callback: Callback< - protos.google.cloud.retail.v2.IAttributesConfig, - protos.google.cloud.retail.v2.IRemoveCatalogAttributeRequest|null|undefined, - {}|null|undefined>): void; - removeCatalogAttribute( - request?: protos.google.cloud.retail.v2.IRemoveCatalogAttributeRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2.IAttributesConfig, - protos.google.cloud.retail.v2.IRemoveCatalogAttributeRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2.IAttributesConfig, - protos.google.cloud.retail.v2.IRemoveCatalogAttributeRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2.IAttributesConfig, - protos.google.cloud.retail.v2.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' - ] = this._gaxModule.routingHeader.fromParams({ - 'attributes_config': request.attributesConfig ?? '', - }); - this.initialize(); - return this.innerApiCalls.removeCatalogAttribute(request, options, callback); - } -/** - * Replaces the specified - * {@link google.cloud.retail.v2.CatalogAttribute|CatalogAttribute} in the - * {@link google.cloud.retail.v2.AttributesConfig|AttributesConfig} by updating the - * catalog attribute with the same - * {@link google.cloud.retail.v2.CatalogAttribute.key|CatalogAttribute.key}. - * - * If the {@link google.cloud.retail.v2.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.v2.CatalogAttribute} request.catalogAttribute - * Required. The updated - * {@link google.cloud.retail.v2.CatalogAttribute|CatalogAttribute}. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided - * {@link google.cloud.retail.v2.CatalogAttribute|CatalogAttribute} to update. The - * following are NOT supported: - * - * * {@link google.cloud.retail.v2.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 {@link google.cloud.retail.v2.AttributesConfig | 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/v2/catalog_service.replace_catalog_attribute.js - * region_tag:retail_v2_generated_CatalogService_ReplaceCatalogAttribute_async - */ - replaceCatalogAttribute( - request?: protos.google.cloud.retail.v2.IReplaceCatalogAttributeRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2.IAttributesConfig, - protos.google.cloud.retail.v2.IReplaceCatalogAttributeRequest|undefined, {}|undefined - ]>; - replaceCatalogAttribute( - request: protos.google.cloud.retail.v2.IReplaceCatalogAttributeRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2.IAttributesConfig, - protos.google.cloud.retail.v2.IReplaceCatalogAttributeRequest|null|undefined, - {}|null|undefined>): void; - replaceCatalogAttribute( - request: protos.google.cloud.retail.v2.IReplaceCatalogAttributeRequest, - callback: Callback< - protos.google.cloud.retail.v2.IAttributesConfig, - protos.google.cloud.retail.v2.IReplaceCatalogAttributeRequest|null|undefined, - {}|null|undefined>): void; - replaceCatalogAttribute( - request?: protos.google.cloud.retail.v2.IReplaceCatalogAttributeRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2.IAttributesConfig, - protos.google.cloud.retail.v2.IReplaceCatalogAttributeRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2.IAttributesConfig, - protos.google.cloud.retail.v2.IReplaceCatalogAttributeRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2.IAttributesConfig, - protos.google.cloud.retail.v2.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' - ] = this._gaxModule.routingHeader.fromParams({ - 'attributes_config': request.attributesConfig ?? '', - }); - this.initialize(); - return this.innerApiCalls.replaceCatalogAttribute(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 {@link google.cloud.retail.v2.Catalog | 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' - ] = this._gaxModule.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 {@link google.cloud.retail.v2.Catalog | 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' - ] = this._gaxModule.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 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 - * {@link google.cloud.retail.v2.Catalog | 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' - ] = this._gaxModule.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 {}, - callSettings - ) as AsyncIterable; - } -/** - * Gets information about a location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Resource name for the location. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * ``` - * const [response] = await client.getLocation(request); - * ``` - */ - getLocation( - request: LocationProtos.google.cloud.location.IGetLocationRequest, - options?: - | gax.CallOptions - | Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - > - ): Promise { - return this.locationsClient.getLocation(request, options, callback); - } - -/** - * Lists information about the supported locations for this service. Returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The resource that owns the locations collection, if applicable. - * @param {string} request.filter - * The standard list filter. - * @param {number} request.pageSize - * The standard list page size. - * @param {string} request.pageToken - * The standard list page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example - * ``` - * const iterable = client.listLocationsAsync(request); - * for await (const response of iterable) { - * // process response - * } - * ``` - */ - listLocationsAsync( - request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions - ): AsyncIterable { - return this.locationsClient.listLocationsAsync(request, options); - } - -/** - * Gets the latest state of a long-running operation. Clients can use this - * method to poll the operation result at intervals as recommended by the API - * service. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error, ?Object)=} callback - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * const name = ''; - * const [response] = await client.getOperation({name}); - * // doThingsWith(response) - * ``` - */ - getOperation( - request: protos.google.longrunning.GetOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - > - ): Promise<[protos.google.longrunning.Operation]> { - return this.operationsClient.getOperation(request, options, callback); - } - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. - * - * For-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation collection. - * @param {string} request.filter - The standard list filter. - * @param {number=} request.pageSize - - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @returns {Object} - * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * for await (const response of client.listOperationsAsync(request)); - * // doThingsWith(response) - * ``` - */ - listOperationsAsync( - request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions - ): AsyncIterable { - return this.operationsClient.listOperationsAsync(request, options); - } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * {@link Operations.GetOperation} or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an {@link Operation.error} value with a {@link google.rpc.Status.code} of - * 1, corresponding to `Code.CANCELLED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be cancelled. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.cancelOperation({name: ''}); - * ``` - */ - cancelOperation( - request: protos.google.longrunning.CancelOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.CancelOperationRequest, - {} | undefined | null - >, - callback?: Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - > - ): Promise { - return this.operationsClient.cancelOperation(request, options, callback); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be deleted. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.deleteOperation({name: ''}); - * ``` - */ - deleteOperation( - request: protos.google.longrunning.DeleteOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - > - ): Promise { - return this.operationsClient.deleteOperation(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified 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 model resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} model - * @returns {string} Resource name string. - */ - modelPath(project:string,location:string,catalog:string,model:string) { - return this.pathTemplates.modelPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - model: model, - }); - } - - /** - * Parse the project from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the project. - */ - matchProjectFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).project; - } - - /** - * Parse the location from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the location. - */ - matchLocationFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).location; - } - - /** - * Parse the catalog from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).catalog; - } - - /** - * Parse the model from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the model. - */ - matchModelFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).model; - } - - /** - * 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(); - this.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-retail/v2/src/v2/catalog_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2/src/v2/catalog_service_client_config.json deleted file mode 100644 index 407c2a8de65..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/src/v2/catalog_service_client_config.json +++ /dev/null @@ -1,90 +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" - }, - "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/google-cloud-retail/v2/src/v2/catalog_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2/src/v2/catalog_service_proto_list.json deleted file mode 100644 index b31d21dbd95..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/src/v2/catalog_service_proto_list.json +++ /dev/null @@ -1,21 +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/control.proto", - "../../protos/google/cloud/retail/v2/control_service.proto", - "../../protos/google/cloud/retail/v2/import_config.proto", - "../../protos/google/cloud/retail/v2/model.proto", - "../../protos/google/cloud/retail/v2/model_service.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/serving_config.proto", - "../../protos/google/cloud/retail/v2/serving_config_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/google-cloud-retail/v2/src/v2/completion_service_client.ts b/owl-bot-staging/google-cloud-retail/v2/src/v2/completion_service_client.ts deleted file mode 100644 index 75353b50940..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/src/v2/completion_service_client.ts +++ /dev/null @@ -1,1294 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, LocationsClient, LocationProtos} 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'; -const version = require('../../../package.json').version; - -/** - * Autocomplete service for retail. - * - * This feature is only available for users who have Retail Search enabled. - * 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}; - locationsClient: LocationsClient; - 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/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new CompletionServiceClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof 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); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - this.locationsClient = new this._gaxModule.LocationsClient( - this._gaxGrpc, - opts - ); - - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - 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}' - ), - modelPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' - ), - 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. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2/{name=projects/*/locations/*/operations/*}',additional_bindings: [{get: '/v2/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',},{get: '/v2/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2/{name=projects/*/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2/{name=projects/*/locations/*}/operations',additional_bindings: [{get: '/v2/{name=projects/*/locations/*/catalogs/*}/operations',},{get: '/v2/{name=projects/*}/operations',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).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 = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.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._opts.fallback - ); - - 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. - * 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 - * Note that this field applies for `user-data` dataset only. For requests - * with `cloud-retail` dataset, setting this field has no effect. - * - * 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. We recommend that you - * leave this field empty. - * - * It can 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 google.cloud.retail.v2.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 {string} request.entity - * The entity for customers that may run multiple different entities, domains, - * sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, - * `google.com`, `youtube.com`, etc. - * If this is set, it should be exactly matched with - * {@link google.cloud.retail.v2.UserEvent.entity|UserEvent.entity} to get - * per-entity autocomplete results. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.retail.v2.CompleteQueryResponse | 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' - ] = this._gaxModule.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. - * 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 is sent to - * specified Pub/Sub topic. The message data is 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' - ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.importCompletionData, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Gets information about a location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Resource name for the location. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * ``` - * const [response] = await client.getLocation(request); - * ``` - */ - getLocation( - request: LocationProtos.google.cloud.location.IGetLocationRequest, - options?: - | gax.CallOptions - | Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - > - ): Promise { - return this.locationsClient.getLocation(request, options, callback); - } - -/** - * Lists information about the supported locations for this service. Returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The resource that owns the locations collection, if applicable. - * @param {string} request.filter - * The standard list filter. - * @param {number} request.pageSize - * The standard list page size. - * @param {string} request.pageToken - * The standard list page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example - * ``` - * const iterable = client.listLocationsAsync(request); - * for await (const response of iterable) { - * // process response - * } - * ``` - */ - listLocationsAsync( - request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions - ): AsyncIterable { - return this.locationsClient.listLocationsAsync(request, options); - } - -/** - * Gets the latest state of a long-running operation. Clients can use this - * method to poll the operation result at intervals as recommended by the API - * service. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error, ?Object)=} callback - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * const name = ''; - * const [response] = await client.getOperation({name}); - * // doThingsWith(response) - * ``` - */ - getOperation( - request: protos.google.longrunning.GetOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - > - ): Promise<[protos.google.longrunning.Operation]> { - return this.operationsClient.getOperation(request, options, callback); - } - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. - * - * For-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation collection. - * @param {string} request.filter - The standard list filter. - * @param {number=} request.pageSize - - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @returns {Object} - * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * for await (const response of client.listOperationsAsync(request)); - * // doThingsWith(response) - * ``` - */ - listOperationsAsync( - request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions - ): AsyncIterable { - return this.operationsClient.listOperationsAsync(request, options); - } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * {@link Operations.GetOperation} or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an {@link Operation.error} value with a {@link google.rpc.Status.code} of - * 1, corresponding to `Code.CANCELLED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be cancelled. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.cancelOperation({name: ''}); - * ``` - */ - cancelOperation( - request: protos.google.longrunning.CancelOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.CancelOperationRequest, - {} | undefined | null - >, - callback?: Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - > - ): Promise { - return this.operationsClient.cancelOperation(request, options, callback); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be deleted. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.deleteOperation({name: ''}); - * ``` - */ - deleteOperation( - request: protos.google.longrunning.DeleteOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - > - ): Promise { - return this.operationsClient.deleteOperation(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified 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 model resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} model - * @returns {string} Resource name string. - */ - modelPath(project:string,location:string,catalog:string,model:string) { - return this.pathTemplates.modelPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - model: model, - }); - } - - /** - * Parse the project from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the project. - */ - matchProjectFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).project; - } - - /** - * Parse the location from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the location. - */ - matchLocationFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).location; - } - - /** - * Parse the catalog from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).catalog; - } - - /** - * Parse the model from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the model. - */ - matchModelFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).model; - } - - /** - * 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.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-retail/v2/src/v2/completion_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2/src/v2/completion_service_client_config.json deleted file mode 100644 index a6bffad0d24..00000000000 --- a/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2/src/v2/completion_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2/src/v2/completion_service_proto_list.json deleted file mode 100644 index b31d21dbd95..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/src/v2/completion_service_proto_list.json +++ /dev/null @@ -1,21 +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/control.proto", - "../../protos/google/cloud/retail/v2/control_service.proto", - "../../protos/google/cloud/retail/v2/import_config.proto", - "../../protos/google/cloud/retail/v2/model.proto", - "../../protos/google/cloud/retail/v2/model_service.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/serving_config.proto", - "../../protos/google/cloud/retail/v2/serving_config_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/google-cloud-retail/v2/src/v2/control_service_client.ts b/owl-bot-staging/google-cloud-retail/v2/src/v2/control_service_client.ts deleted file mode 100644 index 78f749b3fe5..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/src/v2/control_service_client.ts +++ /dev/null @@ -1,1556 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2/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 v2 - */ -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}; - locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - 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/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new ControlServiceClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof 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); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - this.locationsClient = new this._gaxModule.LocationsClient( - this._gaxGrpc, - opts - ); - - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - 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}' - ), - modelPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' - ), - 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') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2/{name=projects/*/locations/*/operations/*}',additional_bindings: [{get: '/v2/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',},{get: '/v2/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2/{name=projects/*/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2/{name=projects/*/locations/*}/operations',additional_bindings: [{get: '/v2/{name=projects/*/locations/*/catalogs/*}/operations',},{get: '/v2/{name=projects/*}/operations',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - - this.descriptors.longrunning = { - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2.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 = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.controlServiceStub) { - return this.controlServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2.ControlService. - this.controlServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2.ControlService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2.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._opts.fallback - ); - - 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.v2.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.v2.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 {@link google.cloud.retail.v2.Control | 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/v2/control_service.create_control.js - * region_tag:retail_v2_generated_ControlService_CreateControl_async - */ - createControl( - request?: protos.google.cloud.retail.v2.ICreateControlRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2.IControl, - protos.google.cloud.retail.v2.ICreateControlRequest|undefined, {}|undefined - ]>; - createControl( - request: protos.google.cloud.retail.v2.ICreateControlRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2.IControl, - protos.google.cloud.retail.v2.ICreateControlRequest|null|undefined, - {}|null|undefined>): void; - createControl( - request: protos.google.cloud.retail.v2.ICreateControlRequest, - callback: Callback< - protos.google.cloud.retail.v2.IControl, - protos.google.cloud.retail.v2.ICreateControlRequest|null|undefined, - {}|null|undefined>): void; - createControl( - request?: protos.google.cloud.retail.v2.ICreateControlRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2.IControl, - protos.google.cloud.retail.v2.ICreateControlRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2.IControl, - protos.google.cloud.retail.v2.ICreateControlRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2.IControl, - protos.google.cloud.retail.v2.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' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createControl(request, options, callback); - } -/** - * Deletes a Control. - * - * If the {@link google.cloud.retail.v2.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 {@link google.protobuf.Empty | 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/control_service.delete_control.js - * region_tag:retail_v2_generated_ControlService_DeleteControl_async - */ - deleteControl( - request?: protos.google.cloud.retail.v2.IDeleteControlRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2.IDeleteControlRequest|undefined, {}|undefined - ]>; - deleteControl( - request: protos.google.cloud.retail.v2.IDeleteControlRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2.IDeleteControlRequest|null|undefined, - {}|null|undefined>): void; - deleteControl( - request: protos.google.cloud.retail.v2.IDeleteControlRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2.IDeleteControlRequest|null|undefined, - {}|null|undefined>): void; - deleteControl( - request?: protos.google.cloud.retail.v2.IDeleteControlRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2.IDeleteControlRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2.IDeleteControlRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2.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' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteControl(request, options, callback); - } -/** - * Updates a Control. - * - * {@link google.cloud.retail.v2.Control|Control} cannot be set to a different - * oneof field, if so an INVALID_ARGUMENT is returned. If the - * {@link google.cloud.retail.v2.Control|Control} to update does not exist, a - * NOT_FOUND error is returned. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.retail.v2.Control} request.control - * Required. The Control to update. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided - * {@link google.cloud.retail.v2.Control|Control} to update. The following are NOT - * supported: - * - * * {@link google.cloud.retail.v2.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 {@link google.cloud.retail.v2.Control | 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/v2/control_service.update_control.js - * region_tag:retail_v2_generated_ControlService_UpdateControl_async - */ - updateControl( - request?: protos.google.cloud.retail.v2.IUpdateControlRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2.IControl, - protos.google.cloud.retail.v2.IUpdateControlRequest|undefined, {}|undefined - ]>; - updateControl( - request: protos.google.cloud.retail.v2.IUpdateControlRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2.IControl, - protos.google.cloud.retail.v2.IUpdateControlRequest|null|undefined, - {}|null|undefined>): void; - updateControl( - request: protos.google.cloud.retail.v2.IUpdateControlRequest, - callback: Callback< - protos.google.cloud.retail.v2.IControl, - protos.google.cloud.retail.v2.IUpdateControlRequest|null|undefined, - {}|null|undefined>): void; - updateControl( - request?: protos.google.cloud.retail.v2.IUpdateControlRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2.IControl, - protos.google.cloud.retail.v2.IUpdateControlRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2.IControl, - protos.google.cloud.retail.v2.IUpdateControlRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2.IControl, - protos.google.cloud.retail.v2.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' - ] = this._gaxModule.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 get. 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 {@link google.cloud.retail.v2.Control | 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/v2/control_service.get_control.js - * region_tag:retail_v2_generated_ControlService_GetControl_async - */ - getControl( - request?: protos.google.cloud.retail.v2.IGetControlRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2.IControl, - protos.google.cloud.retail.v2.IGetControlRequest|undefined, {}|undefined - ]>; - getControl( - request: protos.google.cloud.retail.v2.IGetControlRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2.IControl, - protos.google.cloud.retail.v2.IGetControlRequest|null|undefined, - {}|null|undefined>): void; - getControl( - request: protos.google.cloud.retail.v2.IGetControlRequest, - callback: Callback< - protos.google.cloud.retail.v2.IControl, - protos.google.cloud.retail.v2.IGetControlRequest|null|undefined, - {}|null|undefined>): void; - getControl( - request?: protos.google.cloud.retail.v2.IGetControlRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2.IControl, - protos.google.cloud.retail.v2.IGetControlRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2.IControl, - protos.google.cloud.retail.v2.IGetControlRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2.IControl, - protos.google.cloud.retail.v2.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' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getControl(request, options, callback); - } - - /** - * Lists all Controls by their parent - * {@link google.cloud.retail.v2.Catalog|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.v2.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 {@link google.cloud.retail.v2.Control | 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.v2.IListControlsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2.IControl[], - protos.google.cloud.retail.v2.IListControlsRequest|null, - protos.google.cloud.retail.v2.IListControlsResponse - ]>; - listControls( - request: protos.google.cloud.retail.v2.IListControlsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.retail.v2.IListControlsRequest, - protos.google.cloud.retail.v2.IListControlsResponse|null|undefined, - protos.google.cloud.retail.v2.IControl>): void; - listControls( - request: protos.google.cloud.retail.v2.IListControlsRequest, - callback: PaginationCallback< - protos.google.cloud.retail.v2.IListControlsRequest, - protos.google.cloud.retail.v2.IListControlsResponse|null|undefined, - protos.google.cloud.retail.v2.IControl>): void; - listControls( - request?: protos.google.cloud.retail.v2.IListControlsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.retail.v2.IListControlsRequest, - protos.google.cloud.retail.v2.IListControlsResponse|null|undefined, - protos.google.cloud.retail.v2.IControl>, - callback?: PaginationCallback< - protos.google.cloud.retail.v2.IListControlsRequest, - protos.google.cloud.retail.v2.IListControlsResponse|null|undefined, - protos.google.cloud.retail.v2.IControl>): - Promise<[ - protos.google.cloud.retail.v2.IControl[], - protos.google.cloud.retail.v2.IListControlsRequest|null, - protos.google.cloud.retail.v2.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' - ] = this._gaxModule.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.v2.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 {@link google.cloud.retail.v2.Control | 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.v2.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' - ] = this._gaxModule.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 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.v2.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 - * {@link google.cloud.retail.v2.Control | 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/v2/control_service.list_controls.js - * region_tag:retail_v2_generated_ControlService_ListControls_async - */ - listControlsAsync( - request?: protos.google.cloud.retail.v2.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' - ] = this._gaxModule.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 {}, - callSettings - ) as AsyncIterable; - } -/** - * Gets information about a location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Resource name for the location. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * ``` - * const [response] = await client.getLocation(request); - * ``` - */ - getLocation( - request: LocationProtos.google.cloud.location.IGetLocationRequest, - options?: - | gax.CallOptions - | Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - > - ): Promise { - return this.locationsClient.getLocation(request, options, callback); - } - -/** - * Lists information about the supported locations for this service. Returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The resource that owns the locations collection, if applicable. - * @param {string} request.filter - * The standard list filter. - * @param {number} request.pageSize - * The standard list page size. - * @param {string} request.pageToken - * The standard list page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example - * ``` - * const iterable = client.listLocationsAsync(request); - * for await (const response of iterable) { - * // process response - * } - * ``` - */ - listLocationsAsync( - request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions - ): AsyncIterable { - return this.locationsClient.listLocationsAsync(request, options); - } - -/** - * Gets the latest state of a long-running operation. Clients can use this - * method to poll the operation result at intervals as recommended by the API - * service. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error, ?Object)=} callback - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * const name = ''; - * const [response] = await client.getOperation({name}); - * // doThingsWith(response) - * ``` - */ - getOperation( - request: protos.google.longrunning.GetOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - > - ): Promise<[protos.google.longrunning.Operation]> { - return this.operationsClient.getOperation(request, options, callback); - } - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. - * - * For-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation collection. - * @param {string} request.filter - The standard list filter. - * @param {number=} request.pageSize - - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @returns {Object} - * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * for await (const response of client.listOperationsAsync(request)); - * // doThingsWith(response) - * ``` - */ - listOperationsAsync( - request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions - ): AsyncIterable { - return this.operationsClient.listOperationsAsync(request, options); - } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * {@link Operations.GetOperation} or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an {@link Operation.error} value with a {@link google.rpc.Status.code} of - * 1, corresponding to `Code.CANCELLED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be cancelled. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.cancelOperation({name: ''}); - * ``` - */ - cancelOperation( - request: protos.google.longrunning.CancelOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.CancelOperationRequest, - {} | undefined | null - >, - callback?: Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - > - ): Promise { - return this.operationsClient.cancelOperation(request, options, callback); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be deleted. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.deleteOperation({name: ''}); - * ``` - */ - deleteOperation( - request: protos.google.longrunning.DeleteOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - > - ): Promise { - return this.operationsClient.deleteOperation(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified 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 model resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} model - * @returns {string} Resource name string. - */ - modelPath(project:string,location:string,catalog:string,model:string) { - return this.pathTemplates.modelPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - model: model, - }); - } - - /** - * Parse the project from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the project. - */ - matchProjectFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).project; - } - - /** - * Parse the location from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the location. - */ - matchLocationFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).location; - } - - /** - * Parse the catalog from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).catalog; - } - - /** - * Parse the model from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the model. - */ - matchModelFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).model; - } - - /** - * 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(); - this.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-retail/v2/src/v2/control_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2/src/v2/control_service_client_config.json deleted file mode 100644 index 004c29452fe..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/src/v2/control_service_client_config.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2.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/google-cloud-retail/v2/src/v2/control_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2/src/v2/control_service_proto_list.json deleted file mode 100644 index b31d21dbd95..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/src/v2/control_service_proto_list.json +++ /dev/null @@ -1,21 +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/control.proto", - "../../protos/google/cloud/retail/v2/control_service.proto", - "../../protos/google/cloud/retail/v2/import_config.proto", - "../../protos/google/cloud/retail/v2/model.proto", - "../../protos/google/cloud/retail/v2/model_service.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/serving_config.proto", - "../../protos/google/cloud/retail/v2/serving_config_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/google-cloud-retail/v2/src/v2/gapic_metadata.json b/owl-bot-staging/google-cloud-retail/v2/src/v2/gapic_metadata.json deleted file mode 100644 index 78e1ab8635a..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/src/v2/gapic_metadata.json +++ /dev/null @@ -1,669 +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" - ] - }, - "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" - ] - } - } - } - } - }, - "ModelService": { - "clients": { - "grpc": { - "libraryClient": "ModelServiceClient", - "rpcs": { - "GetModel": { - "methods": [ - "getModel" - ] - }, - "PauseModel": { - "methods": [ - "pauseModel" - ] - }, - "ResumeModel": { - "methods": [ - "resumeModel" - ] - }, - "DeleteModel": { - "methods": [ - "deleteModel" - ] - }, - "UpdateModel": { - "methods": [ - "updateModel" - ] - }, - "CreateModel": { - "methods": [ - "createModel" - ] - }, - "TuneModel": { - "methods": [ - "tuneModel" - ] - }, - "ListModels": { - "methods": [ - "listModels", - "listModelsStream", - "listModelsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ModelServiceClient", - "rpcs": { - "GetModel": { - "methods": [ - "getModel" - ] - }, - "PauseModel": { - "methods": [ - "pauseModel" - ] - }, - "ResumeModel": { - "methods": [ - "resumeModel" - ] - }, - "DeleteModel": { - "methods": [ - "deleteModel" - ] - }, - "UpdateModel": { - "methods": [ - "updateModel" - ] - }, - "CreateModel": { - "methods": [ - "createModel" - ] - }, - "TuneModel": { - "methods": [ - "tuneModel" - ] - }, - "ListModels": { - "methods": [ - "listModels", - "listModelsStream", - "listModelsAsync" - ] - } - } - } - } - }, - "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/google-cloud-retail/v2/src/v2/index.ts b/owl-bot-staging/google-cloud-retail/v2/src/v2/index.ts deleted file mode 100644 index 24ad5baba84..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/src/v2/index.ts +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** 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 {ModelServiceClient} from './model_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/google-cloud-retail/v2/src/v2/model_service_client.ts b/owl-bot-staging/google-cloud-retail/v2/src/v2/model_service_client.ts deleted file mode 100644 index 380ddade120..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/src/v2/model_service_client.ts +++ /dev/null @@ -1,1811 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2/model_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './model_service_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Service for performing CRUD operations on models. - * Recommendation models contain all the metadata necessary to generate a set of - * models for the `Predict()` API. A model is queried - * indirectly via a ServingConfig, which associates a model with a - * given Placement (e.g. Frequently Bought Together on Home Page). - * - * This service allows you to do the following: - * - * * Initiate training of a model. - * * Pause training of an existing model. - * * List all the available models along with their metadata. - * * Control their tuning schedule. - * @class - * @memberof v2 - */ -export class ModelServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - modelServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ModelServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new ModelServiceClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof ModelServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - this.locationsClient = new this._gaxModule.LocationsClient( - this._gaxGrpc, - opts - ); - - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - 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}' - ), - modelPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' - ), - 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 = { - listModels: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'models') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2/{name=projects/*/locations/*/operations/*}',additional_bindings: [{get: '/v2/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',},{get: '/v2/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2/{name=projects/*/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2/{name=projects/*/locations/*}/operations',additional_bindings: [{get: '/v2/{name=projects/*/locations/*/catalogs/*}/operations',},{get: '/v2/{name=projects/*}/operations',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const createModelResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2.Model') as gax.protobuf.Type; - const createModelMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2.CreateModelMetadata') as gax.protobuf.Type; - const tuneModelResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2.TuneModelResponse') as gax.protobuf.Type; - const tuneModelMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2.TuneModelMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - createModel: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createModelResponse.decode.bind(createModelResponse), - createModelMetadata.decode.bind(createModelMetadata)), - tuneModel: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - tuneModelResponse.decode.bind(tuneModelResponse), - tuneModelMetadata.decode.bind(tuneModelMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2.ModelService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.modelServiceStub) { - return this.modelServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2.ModelService. - this.modelServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2.ModelService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2.ModelService, - 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 modelServiceStubMethods = - ['createModel', 'getModel', 'pauseModel', 'resumeModel', 'deleteModel', 'listModels', 'updateModel', 'tuneModel']; - for (const methodName of modelServiceStubMethods) { - const callPromise = this.modelServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - this.descriptors.longrunning[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor, - this._opts.fallback - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.modelServiceStub; - } - - /** - * 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 -- - // ------------------- -/** - * Gets a model. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the {@link google.cloud.retail.v2.Model|Model} to - * get. Format: - * `projects/{project_number}/locations/{location_id}/catalogs/{catalog}/models/{model_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 {@link google.cloud.retail.v2.Model | Model}. - * Please see 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/model_service.get_model.js - * region_tag:retail_v2_generated_ModelService_GetModel_async - */ - getModel( - request?: protos.google.cloud.retail.v2.IGetModelRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2.IModel, - protos.google.cloud.retail.v2.IGetModelRequest|undefined, {}|undefined - ]>; - getModel( - request: protos.google.cloud.retail.v2.IGetModelRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2.IModel, - protos.google.cloud.retail.v2.IGetModelRequest|null|undefined, - {}|null|undefined>): void; - getModel( - request: protos.google.cloud.retail.v2.IGetModelRequest, - callback: Callback< - protos.google.cloud.retail.v2.IModel, - protos.google.cloud.retail.v2.IGetModelRequest|null|undefined, - {}|null|undefined>): void; - getModel( - request?: protos.google.cloud.retail.v2.IGetModelRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2.IModel, - protos.google.cloud.retail.v2.IGetModelRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2.IModel, - protos.google.cloud.retail.v2.IGetModelRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2.IModel, - protos.google.cloud.retail.v2.IGetModelRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getModel(request, options, callback); - } -/** - * Pauses the training of an existing model. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the model to pause. - * Format: - * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_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 {@link google.cloud.retail.v2.Model | Model}. - * Please see 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/model_service.pause_model.js - * region_tag:retail_v2_generated_ModelService_PauseModel_async - */ - pauseModel( - request?: protos.google.cloud.retail.v2.IPauseModelRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2.IModel, - protos.google.cloud.retail.v2.IPauseModelRequest|undefined, {}|undefined - ]>; - pauseModel( - request: protos.google.cloud.retail.v2.IPauseModelRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2.IModel, - protos.google.cloud.retail.v2.IPauseModelRequest|null|undefined, - {}|null|undefined>): void; - pauseModel( - request: protos.google.cloud.retail.v2.IPauseModelRequest, - callback: Callback< - protos.google.cloud.retail.v2.IModel, - protos.google.cloud.retail.v2.IPauseModelRequest|null|undefined, - {}|null|undefined>): void; - pauseModel( - request?: protos.google.cloud.retail.v2.IPauseModelRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2.IModel, - protos.google.cloud.retail.v2.IPauseModelRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2.IModel, - protos.google.cloud.retail.v2.IPauseModelRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2.IModel, - protos.google.cloud.retail.v2.IPauseModelRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.pauseModel(request, options, callback); - } -/** - * Resumes the training of an existing model. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the model to resume. - * Format: - * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_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 {@link google.cloud.retail.v2.Model | Model}. - * Please see 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/model_service.resume_model.js - * region_tag:retail_v2_generated_ModelService_ResumeModel_async - */ - resumeModel( - request?: protos.google.cloud.retail.v2.IResumeModelRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2.IModel, - protos.google.cloud.retail.v2.IResumeModelRequest|undefined, {}|undefined - ]>; - resumeModel( - request: protos.google.cloud.retail.v2.IResumeModelRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2.IModel, - protos.google.cloud.retail.v2.IResumeModelRequest|null|undefined, - {}|null|undefined>): void; - resumeModel( - request: protos.google.cloud.retail.v2.IResumeModelRequest, - callback: Callback< - protos.google.cloud.retail.v2.IModel, - protos.google.cloud.retail.v2.IResumeModelRequest|null|undefined, - {}|null|undefined>): void; - resumeModel( - request?: protos.google.cloud.retail.v2.IResumeModelRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2.IModel, - protos.google.cloud.retail.v2.IResumeModelRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2.IModel, - protos.google.cloud.retail.v2.IResumeModelRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2.IModel, - protos.google.cloud.retail.v2.IResumeModelRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.resumeModel(request, options, callback); - } -/** - * Deletes an existing model. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the {@link google.cloud.retail.v2.Model|Model} to - * delete. Format: - * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_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 {@link google.protobuf.Empty | 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/model_service.delete_model.js - * region_tag:retail_v2_generated_ModelService_DeleteModel_async - */ - deleteModel( - request?: protos.google.cloud.retail.v2.IDeleteModelRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2.IDeleteModelRequest|undefined, {}|undefined - ]>; - deleteModel( - request: protos.google.cloud.retail.v2.IDeleteModelRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2.IDeleteModelRequest|null|undefined, - {}|null|undefined>): void; - deleteModel( - request: protos.google.cloud.retail.v2.IDeleteModelRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2.IDeleteModelRequest|null|undefined, - {}|null|undefined>): void; - deleteModel( - request?: protos.google.cloud.retail.v2.IDeleteModelRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2.IDeleteModelRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2.IDeleteModelRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2.IDeleteModelRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteModel(request, options, callback); - } -/** - * Update of model metadata. Only fields that - * currently can be updated are: `filtering_option` and - * `periodic_tuning_state`. - * If other values are provided, this API method ignores them. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.retail.v2.Model} request.model - * Required. The body of the updated {@link google.cloud.retail.v2.Model|Model}. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Indicates which fields in the provided 'model' to - * update. If not set, by default updates all fields. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.retail.v2.Model | Model}. - * Please see 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/model_service.update_model.js - * region_tag:retail_v2_generated_ModelService_UpdateModel_async - */ - updateModel( - request?: protos.google.cloud.retail.v2.IUpdateModelRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2.IModel, - protos.google.cloud.retail.v2.IUpdateModelRequest|undefined, {}|undefined - ]>; - updateModel( - request: protos.google.cloud.retail.v2.IUpdateModelRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2.IModel, - protos.google.cloud.retail.v2.IUpdateModelRequest|null|undefined, - {}|null|undefined>): void; - updateModel( - request: protos.google.cloud.retail.v2.IUpdateModelRequest, - callback: Callback< - protos.google.cloud.retail.v2.IModel, - protos.google.cloud.retail.v2.IUpdateModelRequest|null|undefined, - {}|null|undefined>): void; - updateModel( - request?: protos.google.cloud.retail.v2.IUpdateModelRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2.IModel, - protos.google.cloud.retail.v2.IUpdateModelRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2.IModel, - protos.google.cloud.retail.v2.IUpdateModelRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2.IModel, - protos.google.cloud.retail.v2.IUpdateModelRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'model.name': request.model!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateModel(request, options, callback); - } - -/** - * Creates a new model. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource under which to create the model. Format: - * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` - * @param {google.cloud.retail.v2.Model} request.model - * Required. The payload of the {@link google.cloud.retail.v2.Model|Model} to - * create. - * @param {boolean} [request.dryRun] - * Optional. Whether to run a dry run to validate the request (without - * actually creating the model). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [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/model_service.create_model.js - * region_tag:retail_v2_generated_ModelService_CreateModel_async - */ - createModel( - request?: protos.google.cloud.retail.v2.ICreateModelRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createModel( - request: protos.google.cloud.retail.v2.ICreateModelRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createModel( - request: protos.google.cloud.retail.v2.ICreateModelRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createModel( - request?: protos.google.cloud.retail.v2.ICreateModelRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createModel(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createModel()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [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/model_service.create_model.js - * region_tag:retail_v2_generated_ModelService_CreateModel_async - */ - async checkCreateModelProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createModel, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Tunes an existing model. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the model to tune. - * Format: - * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [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/model_service.tune_model.js - * region_tag:retail_v2_generated_ModelService_TuneModel_async - */ - tuneModel( - request?: protos.google.cloud.retail.v2.ITuneModelRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - tuneModel( - request: protos.google.cloud.retail.v2.ITuneModelRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - tuneModel( - request: protos.google.cloud.retail.v2.ITuneModelRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - tuneModel( - request?: protos.google.cloud.retail.v2.ITuneModelRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.tuneModel(request, options, callback); - } -/** - * Check the status of the long running operation returned by `tuneModel()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [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/model_service.tune_model.js - * region_tag:retail_v2_generated_ModelService_TuneModel_async - */ - async checkTuneModelProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.tuneModel, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists all the models linked to this event store. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent for which to list models. - * 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 `ListModels` - * 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 {@link google.cloud.retail.v2.Model | Model}. - * 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 `listModelsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listModels( - request?: protos.google.cloud.retail.v2.IListModelsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2.IModel[], - protos.google.cloud.retail.v2.IListModelsRequest|null, - protos.google.cloud.retail.v2.IListModelsResponse - ]>; - listModels( - request: protos.google.cloud.retail.v2.IListModelsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.retail.v2.IListModelsRequest, - protos.google.cloud.retail.v2.IListModelsResponse|null|undefined, - protos.google.cloud.retail.v2.IModel>): void; - listModels( - request: protos.google.cloud.retail.v2.IListModelsRequest, - callback: PaginationCallback< - protos.google.cloud.retail.v2.IListModelsRequest, - protos.google.cloud.retail.v2.IListModelsResponse|null|undefined, - protos.google.cloud.retail.v2.IModel>): void; - listModels( - request?: protos.google.cloud.retail.v2.IListModelsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.retail.v2.IListModelsRequest, - protos.google.cloud.retail.v2.IListModelsResponse|null|undefined, - protos.google.cloud.retail.v2.IModel>, - callback?: PaginationCallback< - protos.google.cloud.retail.v2.IListModelsRequest, - protos.google.cloud.retail.v2.IListModelsResponse|null|undefined, - protos.google.cloud.retail.v2.IModel>): - Promise<[ - protos.google.cloud.retail.v2.IModel[], - protos.google.cloud.retail.v2.IListModelsRequest|null, - protos.google.cloud.retail.v2.IListModelsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listModels(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 for which to list models. - * 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 `ListModels` - * 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 {@link google.cloud.retail.v2.Model | Model} 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 `listModelsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listModelsStream( - request?: protos.google.cloud.retail.v2.IListModelsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listModels']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listModels.createStream( - this.innerApiCalls.listModels as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listModels`, 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 for which to list models. - * 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 `ListModels` - * 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 - * {@link google.cloud.retail.v2.Model | Model}. 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/model_service.list_models.js - * region_tag:retail_v2_generated_ModelService_ListModels_async - */ - listModelsAsync( - request?: protos.google.cloud.retail.v2.IListModelsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listModels']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listModels.asyncIterate( - this.innerApiCalls['listModels'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } -/** - * Gets information about a location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Resource name for the location. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * ``` - * const [response] = await client.getLocation(request); - * ``` - */ - getLocation( - request: LocationProtos.google.cloud.location.IGetLocationRequest, - options?: - | gax.CallOptions - | Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - > - ): Promise { - return this.locationsClient.getLocation(request, options, callback); - } - -/** - * Lists information about the supported locations for this service. Returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The resource that owns the locations collection, if applicable. - * @param {string} request.filter - * The standard list filter. - * @param {number} request.pageSize - * The standard list page size. - * @param {string} request.pageToken - * The standard list page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example - * ``` - * const iterable = client.listLocationsAsync(request); - * for await (const response of iterable) { - * // process response - * } - * ``` - */ - listLocationsAsync( - request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions - ): AsyncIterable { - return this.locationsClient.listLocationsAsync(request, options); - } - -/** - * Gets the latest state of a long-running operation. Clients can use this - * method to poll the operation result at intervals as recommended by the API - * service. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error, ?Object)=} callback - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * const name = ''; - * const [response] = await client.getOperation({name}); - * // doThingsWith(response) - * ``` - */ - getOperation( - request: protos.google.longrunning.GetOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - > - ): Promise<[protos.google.longrunning.Operation]> { - return this.operationsClient.getOperation(request, options, callback); - } - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. - * - * For-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation collection. - * @param {string} request.filter - The standard list filter. - * @param {number=} request.pageSize - - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @returns {Object} - * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * for await (const response of client.listOperationsAsync(request)); - * // doThingsWith(response) - * ``` - */ - listOperationsAsync( - request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions - ): AsyncIterable { - return this.operationsClient.listOperationsAsync(request, options); - } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * {@link Operations.GetOperation} or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an {@link Operation.error} value with a {@link google.rpc.Status.code} of - * 1, corresponding to `Code.CANCELLED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be cancelled. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.cancelOperation({name: ''}); - * ``` - */ - cancelOperation( - request: protos.google.longrunning.CancelOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.CancelOperationRequest, - {} | undefined | null - >, - callback?: Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - > - ): Promise { - return this.operationsClient.cancelOperation(request, options, callback); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be deleted. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.deleteOperation({name: ''}); - * ``` - */ - deleteOperation( - request: protos.google.longrunning.DeleteOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - > - ): Promise { - return this.operationsClient.deleteOperation(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified 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 model resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} model - * @returns {string} Resource name string. - */ - modelPath(project:string,location:string,catalog:string,model:string) { - return this.pathTemplates.modelPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - model: model, - }); - } - - /** - * Parse the project from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the project. - */ - matchProjectFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).project; - } - - /** - * Parse the location from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the location. - */ - matchLocationFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).location; - } - - /** - * Parse the catalog from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).catalog; - } - - /** - * Parse the model from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the model. - */ - matchModelFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).model; - } - - /** - * 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.modelServiceStub && !this._terminated) { - return this.modelServiceStub.then(stub => { - this._terminated = true; - stub.close(); - this.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-retail/v2/src/v2/model_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2/src/v2/model_service_client_config.json deleted file mode 100644 index 715c5647056..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/src/v2/model_service_client_config.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2.ModelService": { - "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": { - "CreateModel": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetModel": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "PauseModel": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ResumeModel": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "DeleteModel": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ListModels": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "UpdateModel": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "TuneModel": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-retail/v2/src/v2/model_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2/src/v2/model_service_proto_list.json deleted file mode 100644 index b31d21dbd95..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/src/v2/model_service_proto_list.json +++ /dev/null @@ -1,21 +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/control.proto", - "../../protos/google/cloud/retail/v2/control_service.proto", - "../../protos/google/cloud/retail/v2/import_config.proto", - "../../protos/google/cloud/retail/v2/model.proto", - "../../protos/google/cloud/retail/v2/model_service.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/serving_config.proto", - "../../protos/google/cloud/retail/v2/serving_config_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/google-cloud-retail/v2/src/v2/prediction_service_client.ts b/owl-bot-staging/google-cloud-retail/v2/src/v2/prediction_service_client.ts deleted file mode 100644 index 60fcf9c0fae..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/src/v2/prediction_service_client.ts +++ /dev/null @@ -1,1226 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LocationsClient, LocationProtos} 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}; - locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - 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/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new PredictionServiceClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof 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); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - this.locationsClient = new this._gaxModule.LocationsClient( - this._gaxGrpc, - opts - ); - - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - 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}' - ), - modelPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' - ), - 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. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2/{name=projects/*/locations/*/operations/*}',additional_bindings: [{get: '/v2/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',},{get: '/v2/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2/{name=projects/*/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2/{name=projects/*/locations/*}/operations',additional_bindings: [{get: '/v2/{name=projects/*/locations/*/catalogs/*}/operations',},{get: '/v2/{name=projects/*}/operations',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - - this.descriptors.longrunning = { - }; - - // 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 = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.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._opts.fallback - ); - - 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: - * `{placement=projects/* /locations/global/catalogs/default_catalog/servingConfigs/*}` - * or - * `{placement=projects/* /locations/global/catalogs/default_catalog/placements/*}`. - * We recommend using the `servingConfigs` resource. `placements` is a legacy - * resource. - * The ID of the Recommendations AI serving config or placement. - * Before you can request predictions from your model, you must create at - * least one serving config or placement for it. For more information, see - * [Manage serving configs] - * (https://cloud.google.com/retail/docs/manage-configs). - * - * The full list of available serving configs can be seen at - * https://console.cloud.google.com/ai/retail/catalogs/default_catalog/configs - * @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. 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 - * This field is not used; leave it unset. - * @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 *no* - * results. If instead you want empty result sets to return generic - * (unfiltered) popular products, set `strictFiltering` to False in - * `PredictRequest.params`. Note that the API will never return items with - * storageStatus of "EXPIRED" or "DELETED" regardless of filter choices. - * - * If `filterSyntaxV2` is set to true under the `params` field, then - * attribute-based expressions are expected instead of the above described - * tag-based syntax. Examples: - * - * * (colors: ANY("Red", "Blue")) AND NOT (categories: ANY("Phones")) - * * (availability: ANY("IN_STOCK")) AND - * (colors: ANY("Red") OR categories: ANY("Phones")) - * - * For more information, see - * [Filter recommendations](https://cloud.google.com/retail/docs/filter-recs). - * @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 a 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. - * * `filterSyntaxV2`: Boolean. False by default. If set to true, the `filter` - * field is interpreteted according to the new, attribute-based syntax. - * @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 {@link google.cloud.retail.v2.PredictResponse | 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'placement': request.placement ?? '', - }); - this.initialize(); - return this.innerApiCalls.predict(request, options, callback); - } - -/** - * Gets information about a location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Resource name for the location. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * ``` - * const [response] = await client.getLocation(request); - * ``` - */ - getLocation( - request: LocationProtos.google.cloud.location.IGetLocationRequest, - options?: - | gax.CallOptions - | Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - > - ): Promise { - return this.locationsClient.getLocation(request, options, callback); - } - -/** - * Lists information about the supported locations for this service. Returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The resource that owns the locations collection, if applicable. - * @param {string} request.filter - * The standard list filter. - * @param {number} request.pageSize - * The standard list page size. - * @param {string} request.pageToken - * The standard list page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example - * ``` - * const iterable = client.listLocationsAsync(request); - * for await (const response of iterable) { - * // process response - * } - * ``` - */ - listLocationsAsync( - request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions - ): AsyncIterable { - return this.locationsClient.listLocationsAsync(request, options); - } - -/** - * Gets the latest state of a long-running operation. Clients can use this - * method to poll the operation result at intervals as recommended by the API - * service. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error, ?Object)=} callback - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * const name = ''; - * const [response] = await client.getOperation({name}); - * // doThingsWith(response) - * ``` - */ - getOperation( - request: protos.google.longrunning.GetOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - > - ): Promise<[protos.google.longrunning.Operation]> { - return this.operationsClient.getOperation(request, options, callback); - } - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. - * - * For-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation collection. - * @param {string} request.filter - The standard list filter. - * @param {number=} request.pageSize - - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @returns {Object} - * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * for await (const response of client.listOperationsAsync(request)); - * // doThingsWith(response) - * ``` - */ - listOperationsAsync( - request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions - ): AsyncIterable { - return this.operationsClient.listOperationsAsync(request, options); - } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * {@link Operations.GetOperation} or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an {@link Operation.error} value with a {@link google.rpc.Status.code} of - * 1, corresponding to `Code.CANCELLED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be cancelled. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.cancelOperation({name: ''}); - * ``` - */ - cancelOperation( - request: protos.google.longrunning.CancelOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.CancelOperationRequest, - {} | undefined | null - >, - callback?: Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - > - ): Promise { - return this.operationsClient.cancelOperation(request, options, callback); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be deleted. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.deleteOperation({name: ''}); - * ``` - */ - deleteOperation( - request: protos.google.longrunning.DeleteOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - > - ): Promise { - return this.operationsClient.deleteOperation(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified 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 model resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} model - * @returns {string} Resource name string. - */ - modelPath(project:string,location:string,catalog:string,model:string) { - return this.pathTemplates.modelPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - model: model, - }); - } - - /** - * Parse the project from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the project. - */ - matchProjectFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).project; - } - - /** - * Parse the location from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the location. - */ - matchLocationFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).location; - } - - /** - * Parse the catalog from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).catalog; - } - - /** - * Parse the model from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the model. - */ - matchModelFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).model; - } - - /** - * 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(); - this.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-retail/v2/src/v2/prediction_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2/src/v2/prediction_service_client_config.json deleted file mode 100644 index 9ab95d31a0c..00000000000 --- a/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2/src/v2/prediction_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2/src/v2/prediction_service_proto_list.json deleted file mode 100644 index b31d21dbd95..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/src/v2/prediction_service_proto_list.json +++ /dev/null @@ -1,21 +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/control.proto", - "../../protos/google/cloud/retail/v2/control_service.proto", - "../../protos/google/cloud/retail/v2/import_config.proto", - "../../protos/google/cloud/retail/v2/model.proto", - "../../protos/google/cloud/retail/v2/model_service.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/serving_config.proto", - "../../protos/google/cloud/retail/v2/serving_config_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/google-cloud-retail/v2/src/v2/product_service_client.ts b/owl-bot-staging/google-cloud-retail/v2/src/v2/product_service_client.ts deleted file mode 100644 index 8c7a285b55b..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/src/v2/product_service_client.ts +++ /dev/null @@ -1,2857 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/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'; -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}; - locationsClient: LocationsClient; - 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/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new ProductServiceClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof 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); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - this.locationsClient = new this._gaxModule.LocationsClient( - this._gaxGrpc, - opts - ); - - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - 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}' - ), - modelPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' - ), - 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. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2/{name=projects/*/locations/*/operations/*}',additional_bindings: [{get: '/v2/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',},{get: '/v2/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2/{name=projects/*/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2/{name=projects/*/locations/*}/operations',additional_bindings: [{get: '/v2/{name=projects/*/locations/*/catalogs/*}/operations',},{get: '/v2/{name=projects/*}/operations',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).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 = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.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._opts.fallback - ); - - 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 {@link google.cloud.retail.v2.Product | 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' - ] = this._gaxModule.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 {@link google.cloud.retail.v2.Product | 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' - ] = this._gaxModule.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 {@link google.cloud.retail.v2.Product | 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' - ] = this._gaxModule.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 {@link google.protobuf.Empty | 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' - ] = this._gaxModule.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, all fields are updated. - * @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 is sent to - * specified Pub/Sub topic. The message data is 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 `service-@gcp-sa-retail.iam.gserviceaccount.com` has the - * `pubsub.topics.publish` IAM permission on the 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/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' - ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.importProducts, this._gaxModule.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 is 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|ProductService.GetProduct} - * or - * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts}. - * - * When inventory is updated with - * {@link google.cloud.retail.v2.ProductService.CreateProduct|ProductService.CreateProduct} - * and - * {@link google.cloud.retail.v2.ProductService.UpdateProduct|ProductService.UpdateProduct}, - * the specified inventory field value(s) overwrite any existing value(s) - * while ignoring the last update time for this field. Furthermore, the last - * update times for the specified inventory fields are overwritten by the - * times of the - * {@link google.cloud.retail.v2.ProductService.CreateProduct|ProductService.CreateProduct} - * or - * {@link google.cloud.retail.v2.ProductService.UpdateProduct|ProductService.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 is used. - * - * If no inventory fields are set in - * {@link google.cloud.retail.v2.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask}, - * then any existing inventory information is preserved. - * - * Pre-existing inventory information can only be updated with - * {@link google.cloud.retail.v2.ProductService.SetInventory|ProductService.SetInventory}, - * {@link google.cloud.retail.v2.ProductService.AddFulfillmentPlaces|ProductService.AddFulfillmentPlaces}, - * and - * {@link google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces|ProductService.RemoveFulfillmentPlaces}. - * - * The returned {@link google.longrunning.Operation|Operation}s is obsolete after - * one day, and the {@link google.longrunning.Operations.GetOperation|GetOperation} - * API returns `NOT_FOUND` afterwards. - * - * If conflicting updates are issued, the - * {@link google.longrunning.Operation|Operation}s associated with the stale - * updates are not marked as {@link google.longrunning.Operation.done|done} until - * they are obsolete. - * - * @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 google.cloud.retail.v2.Product.name|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 google.cloud.retail.v2.Product.fulfillment_info|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 google.cloud.retail.v2.Product.fulfillment_info|SetInventoryRequest.inventory.fulfillment_info} - * * Checks that only the desired fulfillment info types have empty - * {@link google.cloud.retail.v2.FulfillmentInfo.place_ids|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 google.cloud.retail.v2.ProductService.UpdateProduct|ProductService.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' - ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.setInventory, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * It is recommended to use the - * {@link google.cloud.retail.v2.ProductService.AddLocalInventories|ProductService.AddLocalInventories} - * method instead of - * {@link google.cloud.retail.v2.ProductService.AddFulfillmentPlaces|ProductService.AddFulfillmentPlaces}. - * {@link google.cloud.retail.v2.ProductService.AddLocalInventories|ProductService.AddLocalInventories} - * achieves the same results but provides more fine-grained control over - * ingesting local inventory data. - * - * 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|ProductService.GetProduct} - * or - * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts}. - * - * The returned {@link google.longrunning.Operation|Operation}s will be obsolete - * after 1 day, and {@link google.longrunning.Operations.GetOperation|GetOperation} - * API will return NOT_FOUND afterwards. - * - * If conflicting updates are issued, the - * {@link google.longrunning.Operation|Operation}s associated with the stale - * updates will not be marked as {@link google.longrunning.Operation.done|done} - * until being obsolete. - * - * @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.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' - ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.addFulfillmentPlaces, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * It is recommended to use the - * {@link google.cloud.retail.v2.ProductService.RemoveLocalInventories|ProductService.RemoveLocalInventories} - * method instead of - * {@link google.cloud.retail.v2.ProductService.RemoveFulfillmentPlaces|ProductService.RemoveFulfillmentPlaces}. - * {@link google.cloud.retail.v2.ProductService.RemoveLocalInventories|ProductService.RemoveLocalInventories} - * achieves the same results but provides more fine-grained control over - * ingesting local inventory data. - * - * 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|ProductService.GetProduct} - * or - * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts}. - * - * The returned {@link google.longrunning.Operation|Operation}s will be obsolete - * after 1 day, and {@link google.longrunning.Operations.GetOperation|GetOperation} - * API will return NOT_FOUND afterwards. - * - * If conflicting updates are issued, the - * {@link google.longrunning.Operation|Operation}s associated with the stale - * updates will not be marked as {@link google.longrunning.Operation.done|done} - * until being obsolete. - * - * @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' - ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.removeFulfillmentPlaces, this._gaxModule.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|ProductService.GetProduct} - * or - * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts}. - * - * Local inventory information can only be modified using this method. - * {@link google.cloud.retail.v2.ProductService.CreateProduct|ProductService.CreateProduct} - * and - * {@link google.cloud.retail.v2.ProductService.UpdateProduct|ProductService.UpdateProduct} - * has no effect on local inventories. - * - * The returned {@link google.longrunning.Operation|Operation}s will be obsolete - * after 1 day, and {@link google.longrunning.Operations.GetOperation|GetOperation} - * API will return NOT_FOUND afterwards. - * - * If conflicting updates are issued, the - * {@link google.longrunning.Operation|Operation}s associated with the stale - * updates will not be marked as {@link google.longrunning.Operation.done|done} - * until being obsolete. - * - * @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' - ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.addLocalInventories, this._gaxModule.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|ProductService.GetProduct} - * or - * {@link google.cloud.retail.v2.ProductService.ListProducts|ProductService.ListProducts}. - * - * Local inventory information can only be removed using this method. - * {@link google.cloud.retail.v2.ProductService.CreateProduct|ProductService.CreateProduct} - * and - * {@link google.cloud.retail.v2.ProductService.UpdateProduct|ProductService.UpdateProduct} - * has no effect on local inventories. - * - * The returned {@link google.longrunning.Operation|Operation}s will be obsolete - * after 1 day, and {@link google.longrunning.Operations.GetOperation|GetOperation} - * API will return NOT_FOUND afterwards. - * - * If conflicting updates are issued, the - * {@link google.longrunning.Operation|Operation}s associated with the stale - * updates will not be marked as {@link google.longrunning.Operation.done|done} - * until being obsolete. - * - * @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' - ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.removeLocalInventories, this._gaxModule.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 {@link google.cloud.retail.v2.Product | 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listProducts(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The 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 {@link google.cloud.retail.v2.Product | 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listProducts']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProducts.createStream( - this.innerApiCalls.listProducts as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProducts`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The 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 - * {@link google.cloud.retail.v2.Product | 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listProducts']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProducts.asyncIterate( - this.innerApiCalls['listProducts'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } -/** - * Gets information about a location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Resource name for the location. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * ``` - * const [response] = await client.getLocation(request); - * ``` - */ - getLocation( - request: LocationProtos.google.cloud.location.IGetLocationRequest, - options?: - | gax.CallOptions - | Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - > - ): Promise { - return this.locationsClient.getLocation(request, options, callback); - } - -/** - * Lists information about the supported locations for this service. Returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The resource that owns the locations collection, if applicable. - * @param {string} request.filter - * The standard list filter. - * @param {number} request.pageSize - * The standard list page size. - * @param {string} request.pageToken - * The standard list page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example - * ``` - * const iterable = client.listLocationsAsync(request); - * for await (const response of iterable) { - * // process response - * } - * ``` - */ - listLocationsAsync( - request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions - ): AsyncIterable { - return this.locationsClient.listLocationsAsync(request, options); - } - -/** - * Gets the latest state of a long-running operation. Clients can use this - * method to poll the operation result at intervals as recommended by the API - * service. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error, ?Object)=} callback - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * const name = ''; - * const [response] = await client.getOperation({name}); - * // doThingsWith(response) - * ``` - */ - getOperation( - request: protos.google.longrunning.GetOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - > - ): Promise<[protos.google.longrunning.Operation]> { - return this.operationsClient.getOperation(request, options, callback); - } - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. - * - * For-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation collection. - * @param {string} request.filter - The standard list filter. - * @param {number=} request.pageSize - - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @returns {Object} - * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * for await (const response of client.listOperationsAsync(request)); - * // doThingsWith(response) - * ``` - */ - listOperationsAsync( - request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions - ): AsyncIterable { - return this.operationsClient.listOperationsAsync(request, options); - } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * {@link Operations.GetOperation} or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an {@link Operation.error} value with a {@link google.rpc.Status.code} of - * 1, corresponding to `Code.CANCELLED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be cancelled. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.cancelOperation({name: ''}); - * ``` - */ - cancelOperation( - request: protos.google.longrunning.CancelOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.CancelOperationRequest, - {} | undefined | null - >, - callback?: Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - > - ): Promise { - return this.operationsClient.cancelOperation(request, options, callback); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be deleted. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.deleteOperation({name: ''}); - * ``` - */ - deleteOperation( - request: protos.google.longrunning.DeleteOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - > - ): Promise { - return this.operationsClient.deleteOperation(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified 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 model resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} model - * @returns {string} Resource name string. - */ - modelPath(project:string,location:string,catalog:string,model:string) { - return this.pathTemplates.modelPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - model: model, - }); - } - - /** - * Parse the project from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the project. - */ - matchProjectFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).project; - } - - /** - * Parse the location from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the location. - */ - matchLocationFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).location; - } - - /** - * Parse the catalog from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).catalog; - } - - /** - * Parse the model from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the model. - */ - matchModelFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).model; - } - - /** - * 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.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-retail/v2/src/v2/product_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2/src/v2/product_service_client_config.json deleted file mode 100644 index 32245ac6134..00000000000 --- a/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2/src/v2/product_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2/src/v2/product_service_proto_list.json deleted file mode 100644 index b31d21dbd95..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/src/v2/product_service_proto_list.json +++ /dev/null @@ -1,21 +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/control.proto", - "../../protos/google/cloud/retail/v2/control_service.proto", - "../../protos/google/cloud/retail/v2/import_config.proto", - "../../protos/google/cloud/retail/v2/model.proto", - "../../protos/google/cloud/retail/v2/model_service.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/serving_config.proto", - "../../protos/google/cloud/retail/v2/serving_config_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/google-cloud-retail/v2/src/v2/search_service_client.ts b/owl-bot-staging/google-cloud-retail/v2/src/v2/search_service_client.ts deleted file mode 100644 index 40c82dbe8c7..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/src/v2/search_service_client.ts +++ /dev/null @@ -1,2043 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/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. - * 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}; - locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - 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/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new SearchServiceClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof 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); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - this.locationsClient = new this._gaxModule.LocationsClient( - this._gaxGrpc, - opts - ); - - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - 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}' - ), - experimentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/experiments/{experiment}' - ), - modelPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' - ), - 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') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2/{name=projects/*/locations/*/operations/*}',additional_bindings: [{get: '/v2/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',},{get: '/v2/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2/{name=projects/*/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2/{name=projects/*/locations/*}/operations',additional_bindings: [{get: '/v2/{name=projects/*/locations/*/catalogs/*}/operations',},{get: '/v2/{name=projects/*}/operations',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - - this.descriptors.longrunning = { - }; - - // 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 = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.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._opts.fallback - ); - - 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. - * 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 Retail Search serving config, such as - * `projects/* /locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` - * or the name of the legacy placement resource, such as - * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. - * This field is used to identify the serving config 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 200 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 google.cloud.retail.v2.ServingConfig.boost_control_ids|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, 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. - * - * Notice that if both - * {@link google.cloud.retail.v2.ServingConfig.personalization_spec|ServingConfig.personalization_spec} - * and - * {@link google.cloud.retail.v2.SearchRequest.personalization_spec|SearchRequest.personalization_spec} - * are set. - * {@link google.cloud.retail.v2.SearchRequest.personalization_spec|SearchRequest.personalization_spec} - * will override - * {@link google.cloud.retail.v2.ServingConfig.personalization_spec|ServingConfig.personalization_spec}. - * @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 {string} request.entity - * The entity for customers that may run multiple different entities, domains, - * sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, - * `google.com`, `youtube.com`, etc. - * If this is set, it should be exactly matched with - * {@link google.cloud.retail.v2.UserEvent.entity|UserEvent.entity} to get search - * results boosted by entity. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 {@link google.cloud.retail.v2.SearchResponse.SearchResult | 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' - ] = this._gaxModule.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 Retail Search serving config, such as - * `projects/* /locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` - * or the name of the legacy placement resource, such as - * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. - * This field is used to identify the serving config 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 200 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 google.cloud.retail.v2.ServingConfig.boost_control_ids|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, 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. - * - * Notice that if both - * {@link google.cloud.retail.v2.ServingConfig.personalization_spec|ServingConfig.personalization_spec} - * and - * {@link google.cloud.retail.v2.SearchRequest.personalization_spec|SearchRequest.personalization_spec} - * are set. - * {@link google.cloud.retail.v2.SearchRequest.personalization_spec|SearchRequest.personalization_spec} - * will override - * {@link google.cloud.retail.v2.ServingConfig.personalization_spec|ServingConfig.personalization_spec}. - * @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 {string} request.entity - * The entity for customers that may run multiple different entities, domains, - * sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, - * `google.com`, `youtube.com`, etc. - * If this is set, it should be exactly matched with - * {@link google.cloud.retail.v2.UserEvent.entity|UserEvent.entity} to get search - * results boosted by entity. - * @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 {@link google.cloud.retail.v2.SearchResponse.SearchResult | 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' - ] = this._gaxModule.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 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 Retail Search serving config, such as - * `projects/* /locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` - * or the name of the legacy placement resource, such as - * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. - * This field is used to identify the serving config 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 200 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 google.cloud.retail.v2.ServingConfig.boost_control_ids|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, 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. - * - * Notice that if both - * {@link google.cloud.retail.v2.ServingConfig.personalization_spec|ServingConfig.personalization_spec} - * and - * {@link google.cloud.retail.v2.SearchRequest.personalization_spec|SearchRequest.personalization_spec} - * are set. - * {@link google.cloud.retail.v2.SearchRequest.personalization_spec|SearchRequest.personalization_spec} - * will override - * {@link google.cloud.retail.v2.ServingConfig.personalization_spec|ServingConfig.personalization_spec}. - * @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 {string} request.entity - * The entity for customers that may run multiple different entities, domains, - * sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, - * `google.com`, `youtube.com`, etc. - * If this is set, it should be exactly matched with - * {@link google.cloud.retail.v2.UserEvent.entity|UserEvent.entity} to get search - * results boosted by entity. - * @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 - * {@link google.cloud.retail.v2.SearchResponse.SearchResult | 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' - ] = this._gaxModule.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 {}, - callSettings - ) as AsyncIterable; - } -/** - * Gets information about a location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Resource name for the location. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * ``` - * const [response] = await client.getLocation(request); - * ``` - */ - getLocation( - request: LocationProtos.google.cloud.location.IGetLocationRequest, - options?: - | gax.CallOptions - | Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - > - ): Promise { - return this.locationsClient.getLocation(request, options, callback); - } - -/** - * Lists information about the supported locations for this service. Returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The resource that owns the locations collection, if applicable. - * @param {string} request.filter - * The standard list filter. - * @param {number} request.pageSize - * The standard list page size. - * @param {string} request.pageToken - * The standard list page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example - * ``` - * const iterable = client.listLocationsAsync(request); - * for await (const response of iterable) { - * // process response - * } - * ``` - */ - listLocationsAsync( - request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions - ): AsyncIterable { - return this.locationsClient.listLocationsAsync(request, options); - } - -/** - * Gets the latest state of a long-running operation. Clients can use this - * method to poll the operation result at intervals as recommended by the API - * service. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error, ?Object)=} callback - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * const name = ''; - * const [response] = await client.getOperation({name}); - * // doThingsWith(response) - * ``` - */ - getOperation( - request: protos.google.longrunning.GetOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - > - ): Promise<[protos.google.longrunning.Operation]> { - return this.operationsClient.getOperation(request, options, callback); - } - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. - * - * For-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation collection. - * @param {string} request.filter - The standard list filter. - * @param {number=} request.pageSize - - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @returns {Object} - * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * for await (const response of client.listOperationsAsync(request)); - * // doThingsWith(response) - * ``` - */ - listOperationsAsync( - request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions - ): AsyncIterable { - return this.operationsClient.listOperationsAsync(request, options); - } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * {@link Operations.GetOperation} or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an {@link Operation.error} value with a {@link google.rpc.Status.code} of - * 1, corresponding to `Code.CANCELLED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be cancelled. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.cancelOperation({name: ''}); - * ``` - */ - cancelOperation( - request: protos.google.longrunning.CancelOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.CancelOperationRequest, - {} | undefined | null - >, - callback?: Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - > - ): Promise { - return this.operationsClient.cancelOperation(request, options, callback); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be deleted. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.deleteOperation({name: ''}); - * ``` - */ - deleteOperation( - request: protos.google.longrunning.DeleteOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - > - ): Promise { - return this.operationsClient.deleteOperation(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified 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 experiment resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} experiment - * @returns {string} Resource name string. - */ - experimentPath(project:string,location:string,catalog:string,experiment:string) { - return this.pathTemplates.experimentPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - experiment: experiment, - }); - } - - /** - * Parse the project from Experiment resource. - * - * @param {string} experimentName - * A fully-qualified path representing Experiment resource. - * @returns {string} A string representing the project. - */ - matchProjectFromExperimentName(experimentName: string) { - return this.pathTemplates.experimentPathTemplate.match(experimentName).project; - } - - /** - * Parse the location from Experiment resource. - * - * @param {string} experimentName - * A fully-qualified path representing Experiment resource. - * @returns {string} A string representing the location. - */ - matchLocationFromExperimentName(experimentName: string) { - return this.pathTemplates.experimentPathTemplate.match(experimentName).location; - } - - /** - * Parse the catalog from Experiment resource. - * - * @param {string} experimentName - * A fully-qualified path representing Experiment resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromExperimentName(experimentName: string) { - return this.pathTemplates.experimentPathTemplate.match(experimentName).catalog; - } - - /** - * Parse the experiment from Experiment resource. - * - * @param {string} experimentName - * A fully-qualified path representing Experiment resource. - * @returns {string} A string representing the experiment. - */ - matchExperimentFromExperimentName(experimentName: string) { - return this.pathTemplates.experimentPathTemplate.match(experimentName).experiment; - } - - /** - * Return a fully-qualified model resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} model - * @returns {string} Resource name string. - */ - modelPath(project:string,location:string,catalog:string,model:string) { - return this.pathTemplates.modelPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - model: model, - }); - } - - /** - * Parse the project from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the project. - */ - matchProjectFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).project; - } - - /** - * Parse the location from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the location. - */ - matchLocationFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).location; - } - - /** - * Parse the catalog from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).catalog; - } - - /** - * Parse the model from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the model. - */ - matchModelFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).model; - } - - /** - * 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(); - this.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-retail/v2/src/v2/search_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2/src/v2/search_service_client_config.json deleted file mode 100644 index 5132c12db6d..00000000000 --- a/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2/src/v2/search_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2/src/v2/search_service_proto_list.json deleted file mode 100644 index b31d21dbd95..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/src/v2/search_service_proto_list.json +++ /dev/null @@ -1,21 +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/control.proto", - "../../protos/google/cloud/retail/v2/control_service.proto", - "../../protos/google/cloud/retail/v2/import_config.proto", - "../../protos/google/cloud/retail/v2/model.proto", - "../../protos/google/cloud/retail/v2/model_service.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/serving_config.proto", - "../../protos/google/cloud/retail/v2/serving_config_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/google-cloud-retail/v2/src/v2/serving_config_service_client.ts b/owl-bot-staging/google-cloud-retail/v2/src/v2/serving_config_service_client.ts deleted file mode 100644 index c74e80213cf..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/src/v2/serving_config_service_client.ts +++ /dev/null @@ -1,1693 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2/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 v2 - */ -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}; - locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - 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/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new ServingConfigServiceClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof 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); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - this.locationsClient = new this._gaxModule.LocationsClient( - this._gaxGrpc, - opts - ); - - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - 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}' - ), - modelPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' - ), - 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') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2/{name=projects/*/locations/*/operations/*}',additional_bindings: [{get: '/v2/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',},{get: '/v2/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2/{name=projects/*/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2/{name=projects/*/locations/*}/operations',additional_bindings: [{get: '/v2/{name=projects/*/locations/*/catalogs/*}/operations',},{get: '/v2/{name=projects/*}/operations',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - - this.descriptors.longrunning = { - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2.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 = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.servingConfigServiceStub) { - return this.servingConfigServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2.ServingConfigService. - this.servingConfigServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2.ServingConfigService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2.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._opts.fallback - ); - - 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.v2.ServingConfig|ServingConfig}s are - * allowed in a {@link google.cloud.retail.v2.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.v2.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 {@link google.cloud.retail.v2.ServingConfig | 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/v2/serving_config_service.create_serving_config.js - * region_tag:retail_v2_generated_ServingConfigService_CreateServingConfig_async - */ - createServingConfig( - request?: protos.google.cloud.retail.v2.ICreateServingConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2.IServingConfig, - protos.google.cloud.retail.v2.ICreateServingConfigRequest|undefined, {}|undefined - ]>; - createServingConfig( - request: protos.google.cloud.retail.v2.ICreateServingConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2.IServingConfig, - protos.google.cloud.retail.v2.ICreateServingConfigRequest|null|undefined, - {}|null|undefined>): void; - createServingConfig( - request: protos.google.cloud.retail.v2.ICreateServingConfigRequest, - callback: Callback< - protos.google.cloud.retail.v2.IServingConfig, - protos.google.cloud.retail.v2.ICreateServingConfigRequest|null|undefined, - {}|null|undefined>): void; - createServingConfig( - request?: protos.google.cloud.retail.v2.ICreateServingConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2.IServingConfig, - protos.google.cloud.retail.v2.ICreateServingConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2.IServingConfig, - protos.google.cloud.retail.v2.ICreateServingConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2.IServingConfig, - protos.google.cloud.retail.v2.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' - ] = this._gaxModule.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 {@link google.protobuf.Empty | 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/serving_config_service.delete_serving_config.js - * region_tag:retail_v2_generated_ServingConfigService_DeleteServingConfig_async - */ - deleteServingConfig( - request?: protos.google.cloud.retail.v2.IDeleteServingConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2.IDeleteServingConfigRequest|undefined, {}|undefined - ]>; - deleteServingConfig( - request: protos.google.cloud.retail.v2.IDeleteServingConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2.IDeleteServingConfigRequest|null|undefined, - {}|null|undefined>): void; - deleteServingConfig( - request: protos.google.cloud.retail.v2.IDeleteServingConfigRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2.IDeleteServingConfigRequest|null|undefined, - {}|null|undefined>): void; - deleteServingConfig( - request?: protos.google.cloud.retail.v2.IDeleteServingConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2.IDeleteServingConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2.IDeleteServingConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2.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' - ] = this._gaxModule.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.v2.ServingConfig} request.servingConfig - * Required. The ServingConfig to update. - * @param {google.protobuf.FieldMask} request.updateMask - * Indicates which fields in the provided - * {@link google.cloud.retail.v2.ServingConfig|ServingConfig} to update. The - * following are NOT supported: - * - * * {@link google.cloud.retail.v2.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 {@link google.cloud.retail.v2.ServingConfig | 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/v2/serving_config_service.update_serving_config.js - * region_tag:retail_v2_generated_ServingConfigService_UpdateServingConfig_async - */ - updateServingConfig( - request?: protos.google.cloud.retail.v2.IUpdateServingConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2.IServingConfig, - protos.google.cloud.retail.v2.IUpdateServingConfigRequest|undefined, {}|undefined - ]>; - updateServingConfig( - request: protos.google.cloud.retail.v2.IUpdateServingConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2.IServingConfig, - protos.google.cloud.retail.v2.IUpdateServingConfigRequest|null|undefined, - {}|null|undefined>): void; - updateServingConfig( - request: protos.google.cloud.retail.v2.IUpdateServingConfigRequest, - callback: Callback< - protos.google.cloud.retail.v2.IServingConfig, - protos.google.cloud.retail.v2.IUpdateServingConfigRequest|null|undefined, - {}|null|undefined>): void; - updateServingConfig( - request?: protos.google.cloud.retail.v2.IUpdateServingConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2.IServingConfig, - protos.google.cloud.retail.v2.IUpdateServingConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2.IServingConfig, - protos.google.cloud.retail.v2.IUpdateServingConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2.IServingConfig, - protos.google.cloud.retail.v2.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' - ] = this._gaxModule.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 {@link google.cloud.retail.v2.ServingConfig | 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/v2/serving_config_service.get_serving_config.js - * region_tag:retail_v2_generated_ServingConfigService_GetServingConfig_async - */ - getServingConfig( - request?: protos.google.cloud.retail.v2.IGetServingConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2.IServingConfig, - protos.google.cloud.retail.v2.IGetServingConfigRequest|undefined, {}|undefined - ]>; - getServingConfig( - request: protos.google.cloud.retail.v2.IGetServingConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2.IServingConfig, - protos.google.cloud.retail.v2.IGetServingConfigRequest|null|undefined, - {}|null|undefined>): void; - getServingConfig( - request: protos.google.cloud.retail.v2.IGetServingConfigRequest, - callback: Callback< - protos.google.cloud.retail.v2.IServingConfig, - protos.google.cloud.retail.v2.IGetServingConfigRequest|null|undefined, - {}|null|undefined>): void; - getServingConfig( - request?: protos.google.cloud.retail.v2.IGetServingConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2.IServingConfig, - protos.google.cloud.retail.v2.IGetServingConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2.IServingConfig, - protos.google.cloud.retail.v2.IGetServingConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2.IServingConfig, - protos.google.cloud.retail.v2.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' - ] = this._gaxModule.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 {@link google.cloud.retail.v2.ServingConfig | 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/v2/serving_config_service.add_control.js - * region_tag:retail_v2_generated_ServingConfigService_AddControl_async - */ - addControl( - request?: protos.google.cloud.retail.v2.IAddControlRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2.IServingConfig, - protos.google.cloud.retail.v2.IAddControlRequest|undefined, {}|undefined - ]>; - addControl( - request: protos.google.cloud.retail.v2.IAddControlRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2.IServingConfig, - protos.google.cloud.retail.v2.IAddControlRequest|null|undefined, - {}|null|undefined>): void; - addControl( - request: protos.google.cloud.retail.v2.IAddControlRequest, - callback: Callback< - protos.google.cloud.retail.v2.IServingConfig, - protos.google.cloud.retail.v2.IAddControlRequest|null|undefined, - {}|null|undefined>): void; - addControl( - request?: protos.google.cloud.retail.v2.IAddControlRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2.IServingConfig, - protos.google.cloud.retail.v2.IAddControlRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2.IServingConfig, - protos.google.cloud.retail.v2.IAddControlRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2.IServingConfig, - protos.google.cloud.retail.v2.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' - ] = this._gaxModule.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 {@link google.cloud.retail.v2.ServingConfig | 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/v2/serving_config_service.remove_control.js - * region_tag:retail_v2_generated_ServingConfigService_RemoveControl_async - */ - removeControl( - request?: protos.google.cloud.retail.v2.IRemoveControlRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2.IServingConfig, - protos.google.cloud.retail.v2.IRemoveControlRequest|undefined, {}|undefined - ]>; - removeControl( - request: protos.google.cloud.retail.v2.IRemoveControlRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2.IServingConfig, - protos.google.cloud.retail.v2.IRemoveControlRequest|null|undefined, - {}|null|undefined>): void; - removeControl( - request: protos.google.cloud.retail.v2.IRemoveControlRequest, - callback: Callback< - protos.google.cloud.retail.v2.IServingConfig, - protos.google.cloud.retail.v2.IRemoveControlRequest|null|undefined, - {}|null|undefined>): void; - removeControl( - request?: protos.google.cloud.retail.v2.IRemoveControlRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2.IServingConfig, - protos.google.cloud.retail.v2.IRemoveControlRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2.IServingConfig, - protos.google.cloud.retail.v2.IRemoveControlRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2.IServingConfig, - protos.google.cloud.retail.v2.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' - ] = this._gaxModule.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 {@link google.cloud.retail.v2.ServingConfig | 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.v2.IListServingConfigsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2.IServingConfig[], - protos.google.cloud.retail.v2.IListServingConfigsRequest|null, - protos.google.cloud.retail.v2.IListServingConfigsResponse - ]>; - listServingConfigs( - request: protos.google.cloud.retail.v2.IListServingConfigsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.retail.v2.IListServingConfigsRequest, - protos.google.cloud.retail.v2.IListServingConfigsResponse|null|undefined, - protos.google.cloud.retail.v2.IServingConfig>): void; - listServingConfigs( - request: protos.google.cloud.retail.v2.IListServingConfigsRequest, - callback: PaginationCallback< - protos.google.cloud.retail.v2.IListServingConfigsRequest, - protos.google.cloud.retail.v2.IListServingConfigsResponse|null|undefined, - protos.google.cloud.retail.v2.IServingConfig>): void; - listServingConfigs( - request?: protos.google.cloud.retail.v2.IListServingConfigsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.retail.v2.IListServingConfigsRequest, - protos.google.cloud.retail.v2.IListServingConfigsResponse|null|undefined, - protos.google.cloud.retail.v2.IServingConfig>, - callback?: PaginationCallback< - protos.google.cloud.retail.v2.IListServingConfigsRequest, - protos.google.cloud.retail.v2.IListServingConfigsResponse|null|undefined, - protos.google.cloud.retail.v2.IServingConfig>): - Promise<[ - protos.google.cloud.retail.v2.IServingConfig[], - protos.google.cloud.retail.v2.IListServingConfigsRequest|null, - protos.google.cloud.retail.v2.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' - ] = this._gaxModule.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 {@link google.cloud.retail.v2.ServingConfig | 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.v2.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' - ] = this._gaxModule.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 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 - * {@link google.cloud.retail.v2.ServingConfig | 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/v2/serving_config_service.list_serving_configs.js - * region_tag:retail_v2_generated_ServingConfigService_ListServingConfigs_async - */ - listServingConfigsAsync( - request?: protos.google.cloud.retail.v2.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' - ] = this._gaxModule.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 {}, - callSettings - ) as AsyncIterable; - } -/** - * Gets information about a location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Resource name for the location. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * ``` - * const [response] = await client.getLocation(request); - * ``` - */ - getLocation( - request: LocationProtos.google.cloud.location.IGetLocationRequest, - options?: - | gax.CallOptions - | Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - > - ): Promise { - return this.locationsClient.getLocation(request, options, callback); - } - -/** - * Lists information about the supported locations for this service. Returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The resource that owns the locations collection, if applicable. - * @param {string} request.filter - * The standard list filter. - * @param {number} request.pageSize - * The standard list page size. - * @param {string} request.pageToken - * The standard list page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example - * ``` - * const iterable = client.listLocationsAsync(request); - * for await (const response of iterable) { - * // process response - * } - * ``` - */ - listLocationsAsync( - request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions - ): AsyncIterable { - return this.locationsClient.listLocationsAsync(request, options); - } - -/** - * Gets the latest state of a long-running operation. Clients can use this - * method to poll the operation result at intervals as recommended by the API - * service. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error, ?Object)=} callback - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * const name = ''; - * const [response] = await client.getOperation({name}); - * // doThingsWith(response) - * ``` - */ - getOperation( - request: protos.google.longrunning.GetOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - > - ): Promise<[protos.google.longrunning.Operation]> { - return this.operationsClient.getOperation(request, options, callback); - } - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. - * - * For-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation collection. - * @param {string} request.filter - The standard list filter. - * @param {number=} request.pageSize - - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @returns {Object} - * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * for await (const response of client.listOperationsAsync(request)); - * // doThingsWith(response) - * ``` - */ - listOperationsAsync( - request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions - ): AsyncIterable { - return this.operationsClient.listOperationsAsync(request, options); - } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * {@link Operations.GetOperation} or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an {@link Operation.error} value with a {@link google.rpc.Status.code} of - * 1, corresponding to `Code.CANCELLED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be cancelled. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.cancelOperation({name: ''}); - * ``` - */ - cancelOperation( - request: protos.google.longrunning.CancelOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.CancelOperationRequest, - {} | undefined | null - >, - callback?: Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - > - ): Promise { - return this.operationsClient.cancelOperation(request, options, callback); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be deleted. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.deleteOperation({name: ''}); - * ``` - */ - deleteOperation( - request: protos.google.longrunning.DeleteOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - > - ): Promise { - return this.operationsClient.deleteOperation(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified 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 model resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} model - * @returns {string} Resource name string. - */ - modelPath(project:string,location:string,catalog:string,model:string) { - return this.pathTemplates.modelPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - model: model, - }); - } - - /** - * Parse the project from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the project. - */ - matchProjectFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).project; - } - - /** - * Parse the location from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the location. - */ - matchLocationFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).location; - } - - /** - * Parse the catalog from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).catalog; - } - - /** - * Parse the model from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the model. - */ - matchModelFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).model; - } - - /** - * 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(); - this.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-retail/v2/src/v2/serving_config_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2/src/v2/serving_config_service_client_config.json deleted file mode 100644 index 3f5419b8c62..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/src/v2/serving_config_service_client_config.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2.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/google-cloud-retail/v2/src/v2/serving_config_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2/src/v2/serving_config_service_proto_list.json deleted file mode 100644 index b31d21dbd95..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/src/v2/serving_config_service_proto_list.json +++ /dev/null @@ -1,21 +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/control.proto", - "../../protos/google/cloud/retail/v2/control_service.proto", - "../../protos/google/cloud/retail/v2/import_config.proto", - "../../protos/google/cloud/retail/v2/model.proto", - "../../protos/google/cloud/retail/v2/model_service.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/serving_config.proto", - "../../protos/google/cloud/retail/v2/serving_config_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/google-cloud-retail/v2/src/v2/user_event_service_client.ts b/owl-bot-staging/google-cloud-retail/v2/src/v2/user_event_service_client.ts deleted file mode 100644 index 9a7d70026e1..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/src/v2/user_event_service_client.ts +++ /dev/null @@ -1,1559 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, LocationsClient, LocationProtos} 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'; -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}; - locationsClient: LocationsClient; - 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/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new UserEventServiceClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof 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); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - this.locationsClient = new this._gaxModule.LocationsClient( - this._gaxGrpc, - opts - ); - - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - 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}' - ), - modelPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' - ), - 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. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2/{name=projects/*/locations/*/operations/*}',additional_bindings: [{get: '/v2/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',},{get: '/v2/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2/{name=projects/*/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2/{name=projects/*/locations/*}/operations',additional_bindings: [{get: '/v2/{name=projects/*/locations/*/catalogs/*}/operations',},{get: '/v2/{name=projects/*}/operations',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).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 = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.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._opts.fallback - ); - - 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 {boolean} request.writeAsync - * If set to true, the user event will be written asynchronously after - * validation, and the API will respond without waiting for the write. - * Therefore, silent failures can occur even if the API returns success. In - * case of silent failures, error messages can be found in Stackdriver logs. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.retail.v2.UserEvent | 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' - ] = this._gaxModule.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.prebuiltRule - * The prebuilt rule name that can convert a specific type of raw_json. - * For example: "ga4_bq" rule for the GA4 user event schema. - * @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 {string} request.rawJson - * An arbitrary serialized JSON string that contains necessary information - * that can comprise a user event. When this field is specified, the - * user_event field will be ignored. Note: line-delimited JSON is not - * supported, a single JSON only. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.api.HttpBody | 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' - ] = this._gaxModule.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' - ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.purgeUserEvents, this._gaxModule.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' - ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.importUserEvents, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Starts a user-event rejoin operation with latest product catalog. Events - * are not annotated with detailed product information for products that are - * missing from the catalog when the user event is ingested. These - * events are stored as unjoined events with limited usage on training and - * serving. You can use this method to start a join operation on specified - * events with the latest version of product catalog. You can also use this - * method 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' - ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.rejoinUserEvents, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Gets information about a location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Resource name for the location. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * ``` - * const [response] = await client.getLocation(request); - * ``` - */ - getLocation( - request: LocationProtos.google.cloud.location.IGetLocationRequest, - options?: - | gax.CallOptions - | Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - > - ): Promise { - return this.locationsClient.getLocation(request, options, callback); - } - -/** - * Lists information about the supported locations for this service. Returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The resource that owns the locations collection, if applicable. - * @param {string} request.filter - * The standard list filter. - * @param {number} request.pageSize - * The standard list page size. - * @param {string} request.pageToken - * The standard list page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example - * ``` - * const iterable = client.listLocationsAsync(request); - * for await (const response of iterable) { - * // process response - * } - * ``` - */ - listLocationsAsync( - request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions - ): AsyncIterable { - return this.locationsClient.listLocationsAsync(request, options); - } - -/** - * Gets the latest state of a long-running operation. Clients can use this - * method to poll the operation result at intervals as recommended by the API - * service. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error, ?Object)=} callback - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * const name = ''; - * const [response] = await client.getOperation({name}); - * // doThingsWith(response) - * ``` - */ - getOperation( - request: protos.google.longrunning.GetOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - > - ): Promise<[protos.google.longrunning.Operation]> { - return this.operationsClient.getOperation(request, options, callback); - } - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. - * - * For-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation collection. - * @param {string} request.filter - The standard list filter. - * @param {number=} request.pageSize - - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @returns {Object} - * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * for await (const response of client.listOperationsAsync(request)); - * // doThingsWith(response) - * ``` - */ - listOperationsAsync( - request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions - ): AsyncIterable { - return this.operationsClient.listOperationsAsync(request, options); - } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * {@link Operations.GetOperation} or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an {@link Operation.error} value with a {@link google.rpc.Status.code} of - * 1, corresponding to `Code.CANCELLED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be cancelled. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.cancelOperation({name: ''}); - * ``` - */ - cancelOperation( - request: protos.google.longrunning.CancelOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.CancelOperationRequest, - {} | undefined | null - >, - callback?: Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - > - ): Promise { - return this.operationsClient.cancelOperation(request, options, callback); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be deleted. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.deleteOperation({name: ''}); - * ``` - */ - deleteOperation( - request: protos.google.longrunning.DeleteOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - > - ): Promise { - return this.operationsClient.deleteOperation(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified 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 model resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} model - * @returns {string} Resource name string. - */ - modelPath(project:string,location:string,catalog:string,model:string) { - return this.pathTemplates.modelPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - model: model, - }); - } - - /** - * Parse the project from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the project. - */ - matchProjectFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).project; - } - - /** - * Parse the location from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the location. - */ - matchLocationFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).location; - } - - /** - * Parse the catalog from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).catalog; - } - - /** - * Parse the model from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the model. - */ - matchModelFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).model; - } - - /** - * 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.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-retail/v2/src/v2/user_event_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2/src/v2/user_event_service_client_config.json deleted file mode 100644 index a3938b37468..00000000000 --- a/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2/src/v2/user_event_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2/src/v2/user_event_service_proto_list.json deleted file mode 100644 index b31d21dbd95..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/src/v2/user_event_service_proto_list.json +++ /dev/null @@ -1,21 +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/control.proto", - "../../protos/google/cloud/retail/v2/control_service.proto", - "../../protos/google/cloud/retail/v2/import_config.proto", - "../../protos/google/cloud/retail/v2/model.proto", - "../../protos/google/cloud/retail/v2/model_service.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/serving_config.proto", - "../../protos/google/cloud/retail/v2/serving_config_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/google-cloud-retail/v2/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-retail/v2/system-test/fixtures/sample/src/index.js deleted file mode 100644 index b0a6d36778b..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** 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 modelServiceClient = new retail.ModelServiceClient(); - 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/google-cloud-retail/v2/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-retail/v2/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 7ee871ea668..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This 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, ModelServiceClient, 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 doStuffWithModelServiceClient(client: ModelServiceClient) { - 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 modelServiceClient = new ModelServiceClient(); - doStuffWithModelServiceClient(modelServiceClient); - // 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/google-cloud-retail/v2/system-test/install.ts b/owl-bot-staging/google-cloud-retail/v2/system-test/install.ts deleted file mode 100644 index c8f81b25a86..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/system-test/install.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import {packNTest} from 'pack-n-play'; -import {readFileSync} from 'fs'; -import {describe, it} from 'mocha'; - -describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } - }; - await packNTest(options); - }); - - it('JavaScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'JavaScript user can use the library', - ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } - }; - await packNTest(options); - }); - -}); diff --git a/owl-bot-staging/google-cloud-retail/v2/test/gapic_catalog_service_v2.ts b/owl-bot-staging/google-cloud-retail/v2/test/gapic_catalog_service_v2.ts deleted file mode 100644 index 9cbde11b68b..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/test/gapic_catalog_service_v2.ts +++ /dev/null @@ -1,2412 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This 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, operationsProtos, LocationProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function 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', () => { - describe('Common methods', () => { - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.UpdateCatalogRequest', ['catalog', 'name']); - request.catalog.name = defaultValue1; - const expectedHeaderRequestParams = `catalog.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.updateCatalog as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCatalog as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.UpdateCatalogRequest', ['catalog', 'name']); - request.catalog.name = defaultValue1; - const expectedHeaderRequestParams = `catalog.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.updateCatalog as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCatalog as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.UpdateCatalogRequest', ['catalog', 'name']); - request.catalog.name = defaultValue1; - const expectedHeaderRequestParams = `catalog.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateCatalog = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateCatalog(request), expectedError); - const actualRequest = (client.innerApiCalls.updateCatalog as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCatalog as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.UpdateCatalogRequest', ['catalog', 'name']); - request.catalog.name = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.SetDefaultBranchRequest', ['catalog']); - request.catalog = defaultValue1; - const expectedHeaderRequestParams = `catalog=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.setDefaultBranch = stubSimpleCall(expectedResponse); - const [response] = await client.setDefaultBranch(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setDefaultBranch as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setDefaultBranch as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.SetDefaultBranchRequest', ['catalog']); - request.catalog = defaultValue1; - const expectedHeaderRequestParams = `catalog=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.setDefaultBranch as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setDefaultBranch as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.SetDefaultBranchRequest', ['catalog']); - request.catalog = defaultValue1; - const expectedHeaderRequestParams = `catalog=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.setDefaultBranch = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setDefaultBranch(request), expectedError); - const actualRequest = (client.innerApiCalls.setDefaultBranch as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setDefaultBranch as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.SetDefaultBranchRequest', ['catalog']); - request.catalog = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.GetDefaultBranchRequest', ['catalog']); - request.catalog = defaultValue1; - const expectedHeaderRequestParams = `catalog=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getDefaultBranch as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDefaultBranch as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.GetDefaultBranchRequest', ['catalog']); - request.catalog = defaultValue1; - const expectedHeaderRequestParams = `catalog=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getDefaultBranch as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDefaultBranch as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.GetDefaultBranchRequest', ['catalog']); - request.catalog = defaultValue1; - const expectedHeaderRequestParams = `catalog=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getDefaultBranch = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getDefaultBranch(request), expectedError); - const actualRequest = (client.innerApiCalls.getDefaultBranch as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDefaultBranch as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.GetDefaultBranchRequest', ['catalog']); - request.catalog = defaultValue1; - 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.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.GetCompletionConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.GetCompletionConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2.CompletionConfig() - ); - client.innerApiCalls.getCompletionConfig = stubSimpleCall(expectedResponse); - const [response] = await client.getCompletionConfig(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCompletionConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCompletionConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getCompletionConfig 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.GetCompletionConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.GetCompletionConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2.CompletionConfig() - ); - client.innerApiCalls.getCompletionConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getCompletionConfig( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2.ICompletionConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCompletionConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCompletionConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getCompletionConfig 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.GetCompletionConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.GetCompletionConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getCompletionConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getCompletionConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.getCompletionConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCompletionConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getCompletionConfig 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.GetCompletionConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.GetCompletionConfigRequest', ['name']); - request.name = defaultValue1; - 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.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.UpdateCompletionConfigRequest() - ); - request.completionConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.UpdateCompletionConfigRequest', ['completionConfig', 'name']); - request.completionConfig.name = defaultValue1; - const expectedHeaderRequestParams = `completion_config.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2.CompletionConfig() - ); - client.innerApiCalls.updateCompletionConfig = stubSimpleCall(expectedResponse); - const [response] = await client.updateCompletionConfig(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateCompletionConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCompletionConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateCompletionConfig 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.UpdateCompletionConfigRequest() - ); - request.completionConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.UpdateCompletionConfigRequest', ['completionConfig', 'name']); - request.completionConfig.name = defaultValue1; - const expectedHeaderRequestParams = `completion_config.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2.CompletionConfig() - ); - client.innerApiCalls.updateCompletionConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateCompletionConfig( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2.ICompletionConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateCompletionConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCompletionConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateCompletionConfig 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.UpdateCompletionConfigRequest() - ); - request.completionConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.UpdateCompletionConfigRequest', ['completionConfig', 'name']); - request.completionConfig.name = defaultValue1; - const expectedHeaderRequestParams = `completion_config.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateCompletionConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateCompletionConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.updateCompletionConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCompletionConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateCompletionConfig 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.UpdateCompletionConfigRequest() - ); - request.completionConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.UpdateCompletionConfigRequest', ['completionConfig', 'name']); - request.completionConfig.name = defaultValue1; - 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.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.GetAttributesConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.GetAttributesConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2.AttributesConfig() - ); - client.innerApiCalls.getAttributesConfig = stubSimpleCall(expectedResponse); - const [response] = await client.getAttributesConfig(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getAttributesConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAttributesConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getAttributesConfig 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.GetAttributesConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.GetAttributesConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2.AttributesConfig() - ); - client.innerApiCalls.getAttributesConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getAttributesConfig( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2.IAttributesConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getAttributesConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAttributesConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getAttributesConfig 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.GetAttributesConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.GetAttributesConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getAttributesConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getAttributesConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.getAttributesConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAttributesConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getAttributesConfig 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.GetAttributesConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.GetAttributesConfigRequest', ['name']); - request.name = defaultValue1; - 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.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.UpdateAttributesConfigRequest() - ); - request.attributesConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.UpdateAttributesConfigRequest', ['attributesConfig', 'name']); - request.attributesConfig.name = defaultValue1; - const expectedHeaderRequestParams = `attributes_config.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2.AttributesConfig() - ); - client.innerApiCalls.updateAttributesConfig = stubSimpleCall(expectedResponse); - const [response] = await client.updateAttributesConfig(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateAttributesConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateAttributesConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateAttributesConfig 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.UpdateAttributesConfigRequest() - ); - request.attributesConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.UpdateAttributesConfigRequest', ['attributesConfig', 'name']); - request.attributesConfig.name = defaultValue1; - const expectedHeaderRequestParams = `attributes_config.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2.AttributesConfig() - ); - client.innerApiCalls.updateAttributesConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateAttributesConfig( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2.IAttributesConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateAttributesConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateAttributesConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateAttributesConfig 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.UpdateAttributesConfigRequest() - ); - request.attributesConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.UpdateAttributesConfigRequest', ['attributesConfig', 'name']); - request.attributesConfig.name = defaultValue1; - const expectedHeaderRequestParams = `attributes_config.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateAttributesConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateAttributesConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.updateAttributesConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateAttributesConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateAttributesConfig 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.UpdateAttributesConfigRequest() - ); - request.attributesConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.UpdateAttributesConfigRequest', ['attributesConfig', 'name']); - request.attributesConfig.name = defaultValue1; - 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.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.AddCatalogAttributeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.AddCatalogAttributeRequest', ['attributesConfig']); - request.attributesConfig = defaultValue1; - const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2.AttributesConfig() - ); - client.innerApiCalls.addCatalogAttribute = stubSimpleCall(expectedResponse); - const [response] = await client.addCatalogAttribute(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.addCatalogAttribute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addCatalogAttribute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes addCatalogAttribute 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.AddCatalogAttributeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.AddCatalogAttributeRequest', ['attributesConfig']); - request.attributesConfig = defaultValue1; - const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2.AttributesConfig() - ); - client.innerApiCalls.addCatalogAttribute = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.addCatalogAttribute( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2.IAttributesConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.addCatalogAttribute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addCatalogAttribute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes addCatalogAttribute 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.AddCatalogAttributeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.AddCatalogAttributeRequest', ['attributesConfig']); - request.attributesConfig = defaultValue1; - const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.addCatalogAttribute = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.addCatalogAttribute(request), expectedError); - const actualRequest = (client.innerApiCalls.addCatalogAttribute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addCatalogAttribute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes addCatalogAttribute 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.AddCatalogAttributeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.AddCatalogAttributeRequest', ['attributesConfig']); - request.attributesConfig = defaultValue1; - 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.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.RemoveCatalogAttributeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.RemoveCatalogAttributeRequest', ['attributesConfig']); - request.attributesConfig = defaultValue1; - const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2.AttributesConfig() - ); - client.innerApiCalls.removeCatalogAttribute = stubSimpleCall(expectedResponse); - const [response] = await client.removeCatalogAttribute(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.removeCatalogAttribute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeCatalogAttribute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes removeCatalogAttribute 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.RemoveCatalogAttributeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.RemoveCatalogAttributeRequest', ['attributesConfig']); - request.attributesConfig = defaultValue1; - const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2.AttributesConfig() - ); - client.innerApiCalls.removeCatalogAttribute = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.removeCatalogAttribute( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2.IAttributesConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.removeCatalogAttribute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeCatalogAttribute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes removeCatalogAttribute 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.RemoveCatalogAttributeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.RemoveCatalogAttributeRequest', ['attributesConfig']); - request.attributesConfig = defaultValue1; - const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.removeCatalogAttribute = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.removeCatalogAttribute(request), expectedError); - const actualRequest = (client.innerApiCalls.removeCatalogAttribute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeCatalogAttribute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes removeCatalogAttribute 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.RemoveCatalogAttributeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.RemoveCatalogAttributeRequest', ['attributesConfig']); - request.attributesConfig = defaultValue1; - 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.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.ReplaceCatalogAttributeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ReplaceCatalogAttributeRequest', ['attributesConfig']); - request.attributesConfig = defaultValue1; - const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2.AttributesConfig() - ); - client.innerApiCalls.replaceCatalogAttribute = stubSimpleCall(expectedResponse); - const [response] = await client.replaceCatalogAttribute(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.replaceCatalogAttribute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.replaceCatalogAttribute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes replaceCatalogAttribute 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.ReplaceCatalogAttributeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ReplaceCatalogAttributeRequest', ['attributesConfig']); - request.attributesConfig = defaultValue1; - const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2.AttributesConfig() - ); - client.innerApiCalls.replaceCatalogAttribute = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.replaceCatalogAttribute( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2.IAttributesConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.replaceCatalogAttribute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.replaceCatalogAttribute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes replaceCatalogAttribute 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.ReplaceCatalogAttributeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ReplaceCatalogAttributeRequest', ['attributesConfig']); - request.attributesConfig = defaultValue1; - const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.replaceCatalogAttribute = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.replaceCatalogAttribute(request), expectedError); - const actualRequest = (client.innerApiCalls.replaceCatalogAttribute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.replaceCatalogAttribute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes replaceCatalogAttribute 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.ReplaceCatalogAttributeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ReplaceCatalogAttributeRequest', ['attributesConfig']); - request.attributesConfig = defaultValue1; - 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.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.ListCatalogsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ListCatalogsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.listCatalogs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCatalogs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ListCatalogsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.listCatalogs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCatalogs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ListCatalogsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listCatalogs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listCatalogs(request), expectedError); - const actualRequest = (client.innerApiCalls.listCatalogs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCatalogs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ListCatalogsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listCatalogs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ListCatalogsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listCatalogs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ListCatalogsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ListCatalogsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('attributesConfig', () => { - const fakePath = "/rendered/path/attributesConfig"; - 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.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.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('completionConfig', () => { - const fakePath = "/rendered/path/completionConfig"; - 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.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.v2.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.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('model', () => { - const fakePath = "/rendered/path/model"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - model: "modelValue", - }; - const client = new catalogserviceModule.v2.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.modelPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.modelPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('modelPath', () => { - const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.modelPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromModelName', () => { - const result = client.matchProjectFromModelName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromModelName', () => { - const result = client.matchLocationFromModelName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromModelName', () => { - const result = client.matchCatalogFromModelName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchModelFromModelName', () => { - const result = client.matchModelFromModelName(fakePath); - assert.strictEqual(result, "modelValue"); - assert((client.pathTemplates.modelPathTemplate.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)); - }); - }); - - describe('servingConfig', () => { - const fakePath = "/rendered/path/servingConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - serving_config: "servingConfigValue", - }; - const client = new catalogserviceModule.v2.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/google-cloud-retail/v2/test/gapic_completion_service_v2.ts b/owl-bot-staging/google-cloud-retail/v2/test/gapic_completion_service_v2.ts deleted file mode 100644 index 242e0195541..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/test/gapic_completion_service_v2.ts +++ /dev/null @@ -1,1234 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This 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, LocationProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function 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.CompletionServiceClient', () => { - describe('Common methods', () => { - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.CompleteQueryRequest', ['catalog']); - request.catalog = defaultValue1; - const expectedHeaderRequestParams = `catalog=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.CompleteQueryRequest', ['catalog']); - request.catalog = defaultValue1; - const expectedHeaderRequestParams = `catalog=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.CompleteQueryRequest', ['catalog']); - request.catalog = defaultValue1; - const expectedHeaderRequestParams = `catalog=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.completeQuery = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.completeQuery(request), expectedError); - const actualRequest = (client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.CompleteQueryRequest', ['catalog']); - request.catalog = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ImportCompletionDataRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.importCompletionData as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importCompletionData as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ImportCompletionDataRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.importCompletionData as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importCompletionData as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ImportCompletionDataRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importCompletionData = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importCompletionData(request), expectedError); - const actualRequest = (client.innerApiCalls.importCompletionData as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importCompletionData as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ImportCompletionDataRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importCompletionData = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importCompletionData(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.importCompletionData as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importCompletionData as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('attributesConfig', () => { - const fakePath = "/rendered/path/attributesConfig"; - 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.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.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('completionConfig', () => { - const fakePath = "/rendered/path/completionConfig"; - 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.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.v2.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('model', () => { - const fakePath = "/rendered/path/model"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - model: "modelValue", - }; - const client = new completionserviceModule.v2.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.modelPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.modelPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('modelPath', () => { - const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.modelPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromModelName', () => { - const result = client.matchProjectFromModelName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromModelName', () => { - const result = client.matchLocationFromModelName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromModelName', () => { - const result = client.matchCatalogFromModelName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchModelFromModelName', () => { - const result = client.matchModelFromModelName(fakePath); - assert.strictEqual(result, "modelValue"); - assert((client.pathTemplates.modelPathTemplate.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)); - }); - }); - - describe('servingConfig', () => { - const fakePath = "/rendered/path/servingConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - serving_config: "servingConfigValue", - }; - const client = new completionserviceModule.v2.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/google-cloud-retail/v2/test/gapic_control_service_v2.ts b/owl-bot-staging/google-cloud-retail/v2/test/gapic_control_service_v2.ts deleted file mode 100644 index 38fb2a6ce12..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/test/gapic_control_service_v2.ts +++ /dev/null @@ -1,1664 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This 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, operationsProtos, LocationProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function 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.ControlServiceClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = controlserviceModule.v2.ControlServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = controlserviceModule.v2.ControlServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = controlserviceModule.v2.ControlServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new controlserviceModule.v2.ControlServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new controlserviceModule.v2.ControlServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new controlserviceModule.v2.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.v2.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.v2.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.v2.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.v2.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.v2.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.CreateControlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.CreateControlRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2.Control() - ); - client.innerApiCalls.createControl = stubSimpleCall(expectedResponse); - const [response] = await client.createControl(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createControl without error using callback', async () => { - const client = new controlserviceModule.v2.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.CreateControlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.CreateControlRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2.Control() - ); - client.innerApiCalls.createControl = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createControl( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2.IControl|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createControl with error', async () => { - const client = new controlserviceModule.v2.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.CreateControlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.CreateControlRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createControl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createControl(request), expectedError); - const actualRequest = (client.innerApiCalls.createControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createControl with closed client', async () => { - const client = new controlserviceModule.v2.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.CreateControlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.CreateControlRequest', ['parent']); - request.parent = defaultValue1; - 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.v2.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.DeleteControlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.DeleteControlRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteControl = stubSimpleCall(expectedResponse); - const [response] = await client.deleteControl(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteControl without error using callback', async () => { - const client = new controlserviceModule.v2.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.DeleteControlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.DeleteControlRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.deleteControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteControl with error', async () => { - const client = new controlserviceModule.v2.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.DeleteControlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.DeleteControlRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteControl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteControl(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteControl with closed client', async () => { - const client = new controlserviceModule.v2.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.DeleteControlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.DeleteControlRequest', ['name']); - request.name = defaultValue1; - 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.v2.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.UpdateControlRequest() - ); - request.control ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.UpdateControlRequest', ['control', 'name']); - request.control.name = defaultValue1; - const expectedHeaderRequestParams = `control.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2.Control() - ); - client.innerApiCalls.updateControl = stubSimpleCall(expectedResponse); - const [response] = await client.updateControl(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateControl without error using callback', async () => { - const client = new controlserviceModule.v2.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.UpdateControlRequest() - ); - request.control ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.UpdateControlRequest', ['control', 'name']); - request.control.name = defaultValue1; - const expectedHeaderRequestParams = `control.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2.Control() - ); - client.innerApiCalls.updateControl = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateControl( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2.IControl|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateControl with error', async () => { - const client = new controlserviceModule.v2.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.UpdateControlRequest() - ); - request.control ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.UpdateControlRequest', ['control', 'name']); - request.control.name = defaultValue1; - const expectedHeaderRequestParams = `control.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateControl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateControl(request), expectedError); - const actualRequest = (client.innerApiCalls.updateControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateControl with closed client', async () => { - const client = new controlserviceModule.v2.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.UpdateControlRequest() - ); - request.control ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.UpdateControlRequest', ['control', 'name']); - request.control.name = defaultValue1; - 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.v2.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.GetControlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.GetControlRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2.Control() - ); - client.innerApiCalls.getControl = stubSimpleCall(expectedResponse); - const [response] = await client.getControl(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getControl without error using callback', async () => { - const client = new controlserviceModule.v2.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.GetControlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.GetControlRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2.Control() - ); - client.innerApiCalls.getControl = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getControl( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2.IControl|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getControl with error', async () => { - const client = new controlserviceModule.v2.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.GetControlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.GetControlRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getControl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getControl(request), expectedError); - const actualRequest = (client.innerApiCalls.getControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getControl with closed client', async () => { - const client = new controlserviceModule.v2.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.GetControlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.GetControlRequest', ['name']); - request.name = defaultValue1; - 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.v2.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.ListControlsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ListControlsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2.Control()), - generateSampleMessage(new protos.google.cloud.retail.v2.Control()), - generateSampleMessage(new protos.google.cloud.retail.v2.Control()), - ]; - client.innerApiCalls.listControls = stubSimpleCall(expectedResponse); - const [response] = await client.listControls(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listControls as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listControls as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listControls without error using callback', async () => { - const client = new controlserviceModule.v2.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.ListControlsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ListControlsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2.Control()), - generateSampleMessage(new protos.google.cloud.retail.v2.Control()), - generateSampleMessage(new protos.google.cloud.retail.v2.Control()), - ]; - client.innerApiCalls.listControls = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listControls( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2.IControl[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listControls as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listControls as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listControls with error', async () => { - const client = new controlserviceModule.v2.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.ListControlsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ListControlsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listControls = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listControls(request), expectedError); - const actualRequest = (client.innerApiCalls.listControls as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listControls as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listControlsStream without error', async () => { - const client = new controlserviceModule.v2.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.ListControlsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ListControlsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2.Control()), - generateSampleMessage(new protos.google.cloud.retail.v2.Control()), - generateSampleMessage(new protos.google.cloud.retail.v2.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.v2.Control[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2.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( - (client.descriptors.page.listControls.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listControlsStream with error', async () => { - const client = new controlserviceModule.v2.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.ListControlsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ListControlsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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.v2.Control[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2.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( - (client.descriptors.page.listControls.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listControls without error', async () => { - const client = new controlserviceModule.v2.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.ListControlsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ListControlsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2.Control()), - generateSampleMessage(new protos.google.cloud.retail.v2.Control()), - generateSampleMessage(new protos.google.cloud.retail.v2.Control()), - ]; - client.descriptors.page.listControls.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.retail.v2.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( - (client.descriptors.page.listControls.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listControls with error', async () => { - const client = new controlserviceModule.v2.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.ListControlsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ListControlsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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.v2.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( - (client.descriptors.page.listControls.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new controlserviceModule.v2.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new controlserviceModule.v2.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new controlserviceModule.v2.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new controlserviceModule.v2.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new controlserviceModule.v2.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new controlserviceModule.v2.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new controlserviceModule.v2.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new controlserviceModule.v2.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new controlserviceModule.v2.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new controlserviceModule.v2.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new controlserviceModule.v2.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new controlserviceModule.v2.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new controlserviceModule.v2.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new controlserviceModule.v2.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new controlserviceModule.v2.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new controlserviceModule.v2.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('attributesConfig', () => { - const fakePath = "/rendered/path/attributesConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new controlserviceModule.v2.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.v2.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.v2.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.v2.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('model', () => { - const fakePath = "/rendered/path/model"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - model: "modelValue", - }; - const client = new controlserviceModule.v2.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.modelPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.modelPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('modelPath', () => { - const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.modelPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromModelName', () => { - const result = client.matchProjectFromModelName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromModelName', () => { - const result = client.matchLocationFromModelName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromModelName', () => { - const result = client.matchCatalogFromModelName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchModelFromModelName', () => { - const result = client.matchModelFromModelName(fakePath); - assert.strictEqual(result, "modelValue"); - assert((client.pathTemplates.modelPathTemplate.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.v2.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.v2.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/google-cloud-retail/v2/test/gapic_model_service_v2.ts b/owl-bot-staging/google-cloud-retail/v2/test/gapic_model_service_v2.ts deleted file mode 100644 index bdef352c886..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/test/gapic_model_service_v2.ts +++ /dev/null @@ -1,2096 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This 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 modelserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos, LocationProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v2.ModelServiceClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = modelserviceModule.v2.ModelServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = modelserviceModule.v2.ModelServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = modelserviceModule.v2.ModelServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new modelserviceModule.v2.ModelServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.modelServiceStub, undefined); - await client.initialize(); - assert(client.modelServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.modelServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.modelServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new modelserviceModule.v2.ModelServiceClient({ - 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 modelserviceModule.v2.ModelServiceClient({ - 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('getModel', () => { - it('invokes getModel without error', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.GetModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.GetModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2.Model() - ); - client.innerApiCalls.getModel = stubSimpleCall(expectedResponse); - const [response] = await client.getModel(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getModel without error using callback', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.GetModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.GetModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2.Model() - ); - client.innerApiCalls.getModel = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getModel( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2.IModel|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getModel with error', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.GetModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.GetModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getModel = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getModel(request), expectedError); - const actualRequest = (client.innerApiCalls.getModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getModel with closed client', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.GetModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.GetModelRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getModel(request), expectedError); - }); - }); - - describe('pauseModel', () => { - it('invokes pauseModel without error', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.PauseModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.PauseModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2.Model() - ); - client.innerApiCalls.pauseModel = stubSimpleCall(expectedResponse); - const [response] = await client.pauseModel(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.pauseModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pauseModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes pauseModel without error using callback', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.PauseModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.PauseModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2.Model() - ); - client.innerApiCalls.pauseModel = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.pauseModel( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2.IModel|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.pauseModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pauseModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes pauseModel with error', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.PauseModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.PauseModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.pauseModel = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.pauseModel(request), expectedError); - const actualRequest = (client.innerApiCalls.pauseModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pauseModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes pauseModel with closed client', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.PauseModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.PauseModelRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.pauseModel(request), expectedError); - }); - }); - - describe('resumeModel', () => { - it('invokes resumeModel without error', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.ResumeModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ResumeModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2.Model() - ); - client.innerApiCalls.resumeModel = stubSimpleCall(expectedResponse); - const [response] = await client.resumeModel(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resumeModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resumeModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resumeModel without error using callback', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.ResumeModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ResumeModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2.Model() - ); - client.innerApiCalls.resumeModel = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.resumeModel( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2.IModel|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resumeModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resumeModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resumeModel with error', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.ResumeModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ResumeModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.resumeModel = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.resumeModel(request), expectedError); - const actualRequest = (client.innerApiCalls.resumeModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resumeModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resumeModel with closed client', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.ResumeModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ResumeModelRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.resumeModel(request), expectedError); - }); - }); - - describe('deleteModel', () => { - it('invokes deleteModel without error', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.DeleteModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.DeleteModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteModel = stubSimpleCall(expectedResponse); - const [response] = await client.deleteModel(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteModel without error using callback', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.DeleteModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.DeleteModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteModel = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteModel( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteModel with error', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.DeleteModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.DeleteModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteModel = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteModel(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteModel with closed client', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.DeleteModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.DeleteModelRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteModel(request), expectedError); - }); - }); - - describe('updateModel', () => { - it('invokes updateModel without error', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.UpdateModelRequest() - ); - request.model ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.UpdateModelRequest', ['model', 'name']); - request.model.name = defaultValue1; - const expectedHeaderRequestParams = `model.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2.Model() - ); - client.innerApiCalls.updateModel = stubSimpleCall(expectedResponse); - const [response] = await client.updateModel(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateModel without error using callback', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.UpdateModelRequest() - ); - request.model ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.UpdateModelRequest', ['model', 'name']); - request.model.name = defaultValue1; - const expectedHeaderRequestParams = `model.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2.Model() - ); - client.innerApiCalls.updateModel = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateModel( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2.IModel|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateModel with error', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.UpdateModelRequest() - ); - request.model ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.UpdateModelRequest', ['model', 'name']); - request.model.name = defaultValue1; - const expectedHeaderRequestParams = `model.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateModel = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateModel(request), expectedError); - const actualRequest = (client.innerApiCalls.updateModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateModel with closed client', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.UpdateModelRequest() - ); - request.model ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.UpdateModelRequest', ['model', 'name']); - request.model.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateModel(request), expectedError); - }); - }); - - describe('createModel', () => { - it('invokes createModel without error', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.CreateModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.CreateModelRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createModel = stubLongRunningCall(expectedResponse); - const [operation] = await client.createModel(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createModel without error using callback', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.CreateModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.CreateModelRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createModel = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createModel( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createModel with call error', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.CreateModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.CreateModelRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createModel = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createModel(request), expectedError); - const actualRequest = (client.innerApiCalls.createModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createModel with LRO error', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.CreateModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.CreateModelRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createModel = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createModel(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateModelProgress without error', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateModelProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateModelProgress with error', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateModelProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('tuneModel', () => { - it('invokes tuneModel without error', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.TuneModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.TuneModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.tuneModel = stubLongRunningCall(expectedResponse); - const [operation] = await client.tuneModel(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.tuneModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.tuneModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes tuneModel without error using callback', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.TuneModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.TuneModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.tuneModel = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.tuneModel( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.tuneModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.tuneModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes tuneModel with call error', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.TuneModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.TuneModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.tuneModel = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.tuneModel(request), expectedError); - const actualRequest = (client.innerApiCalls.tuneModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.tuneModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes tuneModel with LRO error', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.TuneModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.TuneModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.tuneModel = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.tuneModel(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.tuneModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.tuneModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkTuneModelProgress without error', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkTuneModelProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkTuneModelProgress with error', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkTuneModelProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listModels', () => { - it('invokes listModels without error', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.ListModelsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ListModelsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2.Model()), - generateSampleMessage(new protos.google.cloud.retail.v2.Model()), - generateSampleMessage(new protos.google.cloud.retail.v2.Model()), - ]; - client.innerApiCalls.listModels = stubSimpleCall(expectedResponse); - const [response] = await client.listModels(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listModels as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listModels as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listModels without error using callback', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.ListModelsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ListModelsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2.Model()), - generateSampleMessage(new protos.google.cloud.retail.v2.Model()), - generateSampleMessage(new protos.google.cloud.retail.v2.Model()), - ]; - client.innerApiCalls.listModels = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listModels( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2.IModel[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listModels as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listModels as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listModels with error', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.ListModelsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ListModelsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listModels = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listModels(request), expectedError); - const actualRequest = (client.innerApiCalls.listModels as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listModels as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listModelsStream without error', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.ListModelsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ListModelsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2.Model()), - generateSampleMessage(new protos.google.cloud.retail.v2.Model()), - generateSampleMessage(new protos.google.cloud.retail.v2.Model()), - ]; - client.descriptors.page.listModels.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listModelsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2.Model[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2.Model) => { - 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.listModels.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listModels, request)); - assert( - (client.descriptors.page.listModels.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listModelsStream with error', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.ListModelsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ListModelsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listModels.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listModelsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2.Model[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2.Model) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listModels.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listModels, request)); - assert( - (client.descriptors.page.listModels.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listModels without error', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.ListModelsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ListModelsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2.Model()), - generateSampleMessage(new protos.google.cloud.retail.v2.Model()), - generateSampleMessage(new protos.google.cloud.retail.v2.Model()), - ]; - client.descriptors.page.listModels.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.retail.v2.IModel[] = []; - const iterable = client.listModelsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listModels.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listModels.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listModels with error', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.ListModelsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ListModelsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listModels.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listModelsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.retail.v2.IModel[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listModels.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listModels.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('attributesConfig', () => { - const fakePath = "/rendered/path/attributesConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new modelserviceModule.v2.ModelServiceClient({ - 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 modelserviceModule.v2.ModelServiceClient({ - 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 modelserviceModule.v2.ModelServiceClient({ - 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 modelserviceModule.v2.ModelServiceClient({ - 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('model', () => { - const fakePath = "/rendered/path/model"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - model: "modelValue", - }; - const client = new modelserviceModule.v2.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.modelPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.modelPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('modelPath', () => { - const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.modelPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromModelName', () => { - const result = client.matchProjectFromModelName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromModelName', () => { - const result = client.matchLocationFromModelName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromModelName', () => { - const result = client.matchCatalogFromModelName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchModelFromModelName', () => { - const result = client.matchModelFromModelName(fakePath); - assert.strictEqual(result, "modelValue"); - assert((client.pathTemplates.modelPathTemplate.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 modelserviceModule.v2.ModelServiceClient({ - 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 modelserviceModule.v2.ModelServiceClient({ - 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/google-cloud-retail/v2/test/gapic_prediction_service_v2.ts b/owl-bot-staging/google-cloud-retail/v2/test/gapic_prediction_service_v2.ts deleted file mode 100644 index 239984bb843..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/test/gapic_prediction_service_v2.ts +++ /dev/null @@ -1,1064 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This 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, operationsProtos, LocationProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function 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.PredictionServiceClient', () => { - describe('Common methods', () => { - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.PredictRequest', ['placement']); - request.placement = defaultValue1; - const expectedHeaderRequestParams = `placement=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.predict as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.predict as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.PredictRequest', ['placement']); - request.placement = defaultValue1; - const expectedHeaderRequestParams = `placement=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.predict as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.predict as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.PredictRequest', ['placement']); - request.placement = defaultValue1; - const expectedHeaderRequestParams = `placement=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.predict = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.predict(request), expectedError); - const actualRequest = (client.innerApiCalls.predict as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.predict as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.PredictRequest', ['placement']); - request.placement = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.predict(request), expectedError); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new predictionserviceModule.v2.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new predictionserviceModule.v2.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new predictionserviceModule.v2.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new predictionserviceModule.v2.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new predictionserviceModule.v2.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new predictionserviceModule.v2.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new predictionserviceModule.v2.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new predictionserviceModule.v2.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new predictionserviceModule.v2.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new predictionserviceModule.v2.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new predictionserviceModule.v2.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new predictionserviceModule.v2.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new predictionserviceModule.v2.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new predictionserviceModule.v2.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new predictionserviceModule.v2.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new predictionserviceModule.v2.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('attributesConfig', () => { - const fakePath = "/rendered/path/attributesConfig"; - 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.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.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('completionConfig', () => { - const fakePath = "/rendered/path/completionConfig"; - 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.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.v2.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('model', () => { - const fakePath = "/rendered/path/model"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - model: "modelValue", - }; - const client = new predictionserviceModule.v2.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.modelPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.modelPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('modelPath', () => { - const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.modelPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromModelName', () => { - const result = client.matchProjectFromModelName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromModelName', () => { - const result = client.matchLocationFromModelName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromModelName', () => { - const result = client.matchCatalogFromModelName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchModelFromModelName', () => { - const result = client.matchModelFromModelName(fakePath); - assert.strictEqual(result, "modelValue"); - assert((client.pathTemplates.modelPathTemplate.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)); - }); - }); - - describe('servingConfig', () => { - const fakePath = "/rendered/path/servingConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - serving_config: "servingConfigValue", - }; - const client = new predictionserviceModule.v2.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/google-cloud-retail/v2/test/gapic_product_service_v2.ts b/owl-bot-staging/google-cloud-retail/v2/test/gapic_product_service_v2.ts deleted file mode 100644 index e6afc43d99a..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/test/gapic_product_service_v2.ts +++ /dev/null @@ -1,2662 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This 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, LocationProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v2.ProductServiceClient', () => { - describe('Common methods', () => { - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.CreateProductRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProduct without error using callback', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.CreateProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.CreateProductRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProduct with error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.CreateProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.CreateProductRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createProduct(request), expectedError); - const actualRequest = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProduct with closed client', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.CreateProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.CreateProductRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createProduct(request), expectedError); - }); - }); - - describe('getProduct', () => { - it('invokes getProduct without error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.GetProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.GetProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProduct without error using callback', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.GetProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.GetProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProduct with error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.GetProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.GetProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getProduct(request), expectedError); - const actualRequest = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProduct with closed client', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.GetProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.GetProductRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getProduct(request), expectedError); - }); - }); - - describe('updateProduct', () => { - it('invokes updateProduct without error', async () => { - const client = new 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.UpdateProductRequest', ['product', 'name']); - request.product.name = defaultValue1; - const expectedHeaderRequestParams = `product.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProduct without error using callback', async () => { - const client = new 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.UpdateProductRequest', ['product', 'name']); - request.product.name = defaultValue1; - const expectedHeaderRequestParams = `product.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProduct with error', async () => { - const client = new 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.UpdateProductRequest', ['product', 'name']); - request.product.name = defaultValue1; - const expectedHeaderRequestParams = `product.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateProduct(request), expectedError); - const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProduct with closed client', async () => { - const client = new 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.UpdateProductRequest', ['product', 'name']); - request.product.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateProduct(request), expectedError); - }); - }); - - describe('deleteProduct', () => { - it('invokes deleteProduct without error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.DeleteProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.DeleteProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteProduct = stubSimpleCall(expectedResponse); - const [response] = await client.deleteProduct(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProduct without error using callback', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.DeleteProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.DeleteProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteProduct( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProduct with error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.DeleteProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.DeleteProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteProduct(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProduct with closed client', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.DeleteProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.DeleteProductRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteProduct(request), expectedError); - }); - }); - - describe('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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ImportProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.importProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ImportProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.importProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ImportProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importProducts = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importProducts(request), expectedError); - const actualRequest = (client.innerApiCalls.importProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ImportProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importProducts = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importProducts(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.importProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.SetInventoryRequest', ['inventory', 'name']); - request.inventory.name = defaultValue1; - const expectedHeaderRequestParams = `inventory.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.setInventory as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInventory as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.SetInventoryRequest', ['inventory', 'name']); - request.inventory.name = defaultValue1; - const expectedHeaderRequestParams = `inventory.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.setInventory as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInventory as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.SetInventoryRequest', ['inventory', 'name']); - request.inventory.name = defaultValue1; - const expectedHeaderRequestParams = `inventory.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.setInventory = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.setInventory(request), expectedError); - const actualRequest = (client.innerApiCalls.setInventory as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInventory as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.SetInventoryRequest', ['inventory', 'name']); - request.inventory.name = defaultValue1; - const expectedHeaderRequestParams = `inventory.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.setInventory = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.setInventory(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.setInventory as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInventory as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.AddFulfillmentPlacesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.AddFulfillmentPlacesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.AddFulfillmentPlacesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.addFulfillmentPlaces(request), expectedError); - const actualRequest = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.AddFulfillmentPlacesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.addFulfillmentPlaces(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.removeFulfillmentPlaces(request), expectedError); - const actualRequest = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.removeFulfillmentPlaces(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.AddLocalInventoriesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.addLocalInventories as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addLocalInventories as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.AddLocalInventoriesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.addLocalInventories as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addLocalInventories as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.AddLocalInventoriesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.addLocalInventories = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.addLocalInventories(request), expectedError); - const actualRequest = (client.innerApiCalls.addLocalInventories as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addLocalInventories as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.AddLocalInventoriesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.addLocalInventories = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.addLocalInventories(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.addLocalInventories as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addLocalInventories as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.RemoveLocalInventoriesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.removeLocalInventories as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeLocalInventories as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.RemoveLocalInventoriesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.removeLocalInventories as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeLocalInventories as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.RemoveLocalInventoriesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.removeLocalInventories = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.removeLocalInventories(request), expectedError); - const actualRequest = (client.innerApiCalls.removeLocalInventories as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeLocalInventories as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.RemoveLocalInventoriesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.removeLocalInventories = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.removeLocalInventories(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.removeLocalInventories as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeLocalInventories as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProducts without error using callback', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProducts with error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listProducts = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProducts(request), expectedError); - const actualRequest = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductsStream without error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listProductsStream with error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProducts.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProductsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.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( - (client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProducts without error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProducts with error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProductsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.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( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('attributesConfig', () => { - const fakePath = "/rendered/path/attributesConfig"; - 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.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.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('completionConfig', () => { - const fakePath = "/rendered/path/completionConfig"; - 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.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.v2.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('model', () => { - const fakePath = "/rendered/path/model"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - model: "modelValue", - }; - const client = new productserviceModule.v2.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.modelPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.modelPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('modelPath', () => { - const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.modelPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromModelName', () => { - const result = client.matchProjectFromModelName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromModelName', () => { - const result = client.matchLocationFromModelName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromModelName', () => { - const result = client.matchCatalogFromModelName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchModelFromModelName', () => { - const result = client.matchModelFromModelName(fakePath); - assert.strictEqual(result, "modelValue"); - assert((client.pathTemplates.modelPathTemplate.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)); - }); - }); - - describe('servingConfig', () => { - const fakePath = "/rendered/path/servingConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - serving_config: "servingConfigValue", - }; - const client = new productserviceModule.v2.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/google-cloud-retail/v2/test/gapic_search_service_v2.ts b/owl-bot-staging/google-cloud-retail/v2/test/gapic_search_service_v2.ts deleted file mode 100644 index 33ff392da3b..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/test/gapic_search_service_v2.ts +++ /dev/null @@ -1,1336 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This 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, operationsProtos, LocationProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function 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', () => { - describe('Common methods', () => { - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.SearchRequest', ['placement']); - request.placement = defaultValue1; - const expectedHeaderRequestParams = `placement=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.search as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.search as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.SearchRequest', ['placement']); - request.placement = defaultValue1; - const expectedHeaderRequestParams = `placement=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.search as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.search as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.SearchRequest', ['placement']); - request.placement = defaultValue1; - const expectedHeaderRequestParams = `placement=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.search = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.search(request), expectedError); - const actualRequest = (client.innerApiCalls.search as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.search as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.SearchRequest', ['placement']); - request.placement = defaultValue1; - const expectedHeaderRequestParams = `placement=${defaultValue1}`; - 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( - (client.descriptors.page.search.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.SearchRequest', ['placement']); - request.placement = defaultValue1; - const expectedHeaderRequestParams = `placement=${defaultValue1}`; - 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( - (client.descriptors.page.search.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.SearchRequest', ['placement']); - request.placement = defaultValue1; - const expectedHeaderRequestParams = `placement=${defaultValue1}`; - 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( - (client.descriptors.page.search.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.SearchRequest', ['placement']); - request.placement = defaultValue1; - const expectedHeaderRequestParams = `placement=${defaultValue1}`; - 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( - (client.descriptors.page.search.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('attributesConfig', () => { - const fakePath = "/rendered/path/attributesConfig"; - 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.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.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('completionConfig', () => { - const fakePath = "/rendered/path/completionConfig"; - 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.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.v2.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('experiment', () => { - const fakePath = "/rendered/path/experiment"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - experiment: "experimentValue", - }; - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.experimentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.experimentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('experimentPath', () => { - const result = client.experimentPath("projectValue", "locationValue", "catalogValue", "experimentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.experimentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromExperimentName', () => { - const result = client.matchProjectFromExperimentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.experimentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromExperimentName', () => { - const result = client.matchLocationFromExperimentName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.experimentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromExperimentName', () => { - const result = client.matchCatalogFromExperimentName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.experimentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchExperimentFromExperimentName', () => { - const result = client.matchExperimentFromExperimentName(fakePath); - assert.strictEqual(result, "experimentValue"); - assert((client.pathTemplates.experimentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('model', () => { - const fakePath = "/rendered/path/model"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - model: "modelValue", - }; - const client = new searchserviceModule.v2.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.modelPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.modelPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('modelPath', () => { - const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.modelPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromModelName', () => { - const result = client.matchProjectFromModelName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromModelName', () => { - const result = client.matchLocationFromModelName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromModelName', () => { - const result = client.matchCatalogFromModelName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchModelFromModelName', () => { - const result = client.matchModelFromModelName(fakePath); - assert.strictEqual(result, "modelValue"); - assert((client.pathTemplates.modelPathTemplate.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)); - }); - }); - - describe('servingConfig', () => { - const fakePath = "/rendered/path/servingConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - serving_config: "servingConfigValue", - }; - const client = new searchserviceModule.v2.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/google-cloud-retail/v2/test/gapic_serving_config_service_v2.ts b/owl-bot-staging/google-cloud-retail/v2/test/gapic_serving_config_service_v2.ts deleted file mode 100644 index 62e6d0df6ab..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/test/gapic_serving_config_service_v2.ts +++ /dev/null @@ -1,1880 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This 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, operationsProtos, LocationProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function 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.ServingConfigServiceClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = servingconfigserviceModule.v2.ServingConfigServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = servingconfigserviceModule.v2.ServingConfigServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = servingconfigserviceModule.v2.ServingConfigServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new servingconfigserviceModule.v2.ServingConfigServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new servingconfigserviceModule.v2.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.v2.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.v2.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.v2.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.v2.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.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.CreateServingConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.CreateServingConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2.ServingConfig() - ); - client.innerApiCalls.createServingConfig = stubSimpleCall(expectedResponse); - const [response] = await client.createServingConfig(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createServingConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createServingConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createServingConfig without error using callback', async () => { - const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.CreateServingConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.CreateServingConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2.ServingConfig() - ); - client.innerApiCalls.createServingConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createServingConfig( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2.IServingConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createServingConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createServingConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createServingConfig with error', async () => { - const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.CreateServingConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.CreateServingConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createServingConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createServingConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.createServingConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createServingConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createServingConfig with closed client', async () => { - const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.CreateServingConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.CreateServingConfigRequest', ['parent']); - request.parent = defaultValue1; - 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.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.DeleteServingConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.DeleteServingConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteServingConfig = stubSimpleCall(expectedResponse); - const [response] = await client.deleteServingConfig(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteServingConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteServingConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteServingConfig without error using callback', async () => { - const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.DeleteServingConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.DeleteServingConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.deleteServingConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteServingConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteServingConfig with error', async () => { - const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.DeleteServingConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.DeleteServingConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteServingConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteServingConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteServingConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteServingConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteServingConfig with closed client', async () => { - const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.DeleteServingConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.DeleteServingConfigRequest', ['name']); - request.name = defaultValue1; - 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.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.UpdateServingConfigRequest() - ); - request.servingConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.UpdateServingConfigRequest', ['servingConfig', 'name']); - request.servingConfig.name = defaultValue1; - const expectedHeaderRequestParams = `serving_config.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2.ServingConfig() - ); - client.innerApiCalls.updateServingConfig = stubSimpleCall(expectedResponse); - const [response] = await client.updateServingConfig(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateServingConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateServingConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateServingConfig without error using callback', async () => { - const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.UpdateServingConfigRequest() - ); - request.servingConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.UpdateServingConfigRequest', ['servingConfig', 'name']); - request.servingConfig.name = defaultValue1; - const expectedHeaderRequestParams = `serving_config.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2.ServingConfig() - ); - client.innerApiCalls.updateServingConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateServingConfig( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2.IServingConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateServingConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateServingConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateServingConfig with error', async () => { - const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.UpdateServingConfigRequest() - ); - request.servingConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.UpdateServingConfigRequest', ['servingConfig', 'name']); - request.servingConfig.name = defaultValue1; - const expectedHeaderRequestParams = `serving_config.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateServingConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateServingConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.updateServingConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateServingConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateServingConfig with closed client', async () => { - const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.UpdateServingConfigRequest() - ); - request.servingConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.UpdateServingConfigRequest', ['servingConfig', 'name']); - request.servingConfig.name = defaultValue1; - 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.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.GetServingConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.GetServingConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2.ServingConfig() - ); - client.innerApiCalls.getServingConfig = stubSimpleCall(expectedResponse); - const [response] = await client.getServingConfig(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getServingConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getServingConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getServingConfig without error using callback', async () => { - const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.GetServingConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.GetServingConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2.ServingConfig() - ); - client.innerApiCalls.getServingConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getServingConfig( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2.IServingConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getServingConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getServingConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getServingConfig with error', async () => { - const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.GetServingConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.GetServingConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getServingConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getServingConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.getServingConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getServingConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getServingConfig with closed client', async () => { - const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.GetServingConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.GetServingConfigRequest', ['name']); - request.name = defaultValue1; - 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.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.AddControlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.AddControlRequest', ['servingConfig']); - request.servingConfig = defaultValue1; - const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2.ServingConfig() - ); - client.innerApiCalls.addControl = stubSimpleCall(expectedResponse); - const [response] = await client.addControl(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.addControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes addControl without error using callback', async () => { - const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.AddControlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.AddControlRequest', ['servingConfig']); - request.servingConfig = defaultValue1; - const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2.ServingConfig() - ); - client.innerApiCalls.addControl = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.addControl( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2.IServingConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.addControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes addControl with error', async () => { - const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.AddControlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.AddControlRequest', ['servingConfig']); - request.servingConfig = defaultValue1; - const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.addControl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.addControl(request), expectedError); - const actualRequest = (client.innerApiCalls.addControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes addControl with closed client', async () => { - const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.AddControlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.AddControlRequest', ['servingConfig']); - request.servingConfig = defaultValue1; - 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.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.RemoveControlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.RemoveControlRequest', ['servingConfig']); - request.servingConfig = defaultValue1; - const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2.ServingConfig() - ); - client.innerApiCalls.removeControl = stubSimpleCall(expectedResponse); - const [response] = await client.removeControl(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.removeControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes removeControl without error using callback', async () => { - const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.RemoveControlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.RemoveControlRequest', ['servingConfig']); - request.servingConfig = defaultValue1; - const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2.ServingConfig() - ); - client.innerApiCalls.removeControl = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.removeControl( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2.IServingConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.removeControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes removeControl with error', async () => { - const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.RemoveControlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.RemoveControlRequest', ['servingConfig']); - request.servingConfig = defaultValue1; - const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.removeControl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.removeControl(request), expectedError); - const actualRequest = (client.innerApiCalls.removeControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes removeControl with closed client', async () => { - const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.RemoveControlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.RemoveControlRequest', ['servingConfig']); - request.servingConfig = defaultValue1; - 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.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.ListServingConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ListServingConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2.ServingConfig()), - generateSampleMessage(new protos.google.cloud.retail.v2.ServingConfig()), - generateSampleMessage(new protos.google.cloud.retail.v2.ServingConfig()), - ]; - client.innerApiCalls.listServingConfigs = stubSimpleCall(expectedResponse); - const [response] = await client.listServingConfigs(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listServingConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServingConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listServingConfigs without error using callback', async () => { - const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.ListServingConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ListServingConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2.ServingConfig()), - generateSampleMessage(new protos.google.cloud.retail.v2.ServingConfig()), - generateSampleMessage(new protos.google.cloud.retail.v2.ServingConfig()), - ]; - client.innerApiCalls.listServingConfigs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listServingConfigs( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2.IServingConfig[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listServingConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServingConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listServingConfigs with error', async () => { - const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.ListServingConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ListServingConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listServingConfigs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listServingConfigs(request), expectedError); - const actualRequest = (client.innerApiCalls.listServingConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServingConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listServingConfigsStream without error', async () => { - const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.ListServingConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ListServingConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2.ServingConfig()), - generateSampleMessage(new protos.google.cloud.retail.v2.ServingConfig()), - generateSampleMessage(new protos.google.cloud.retail.v2.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.v2.ServingConfig[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2.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( - (client.descriptors.page.listServingConfigs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listServingConfigsStream with error', async () => { - const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.ListServingConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ListServingConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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.v2.ServingConfig[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2.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( - (client.descriptors.page.listServingConfigs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listServingConfigs without error', async () => { - const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.ListServingConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ListServingConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2.ServingConfig()), - generateSampleMessage(new protos.google.cloud.retail.v2.ServingConfig()), - generateSampleMessage(new protos.google.cloud.retail.v2.ServingConfig()), - ]; - client.descriptors.page.listServingConfigs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.retail.v2.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( - (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listServingConfigs with error', async () => { - const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2.ListServingConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ListServingConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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.v2.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( - (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('attributesConfig', () => { - const fakePath = "/rendered/path/attributesConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new servingconfigserviceModule.v2.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.v2.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.v2.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.v2.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('model', () => { - const fakePath = "/rendered/path/model"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - model: "modelValue", - }; - const client = new servingconfigserviceModule.v2.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.modelPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.modelPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('modelPath', () => { - const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.modelPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromModelName', () => { - const result = client.matchProjectFromModelName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromModelName', () => { - const result = client.matchLocationFromModelName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromModelName', () => { - const result = client.matchCatalogFromModelName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchModelFromModelName', () => { - const result = client.matchModelFromModelName(fakePath); - assert.strictEqual(result, "modelValue"); - assert((client.pathTemplates.modelPathTemplate.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.v2.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.v2.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/google-cloud-retail/v2/test/gapic_user_event_service_v2.ts b/owl-bot-staging/google-cloud-retail/v2/test/gapic_user_event_service_v2.ts deleted file mode 100644 index 999cb43900e..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2/test/gapic_user_event_service_v2.ts +++ /dev/null @@ -1,1650 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This 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, LocationProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function 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.UserEventServiceClient', () => { - describe('Common methods', () => { - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.WriteUserEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.WriteUserEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.WriteUserEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.writeUserEvent = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.writeUserEvent(request), expectedError); - const actualRequest = (client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.WriteUserEventRequest', ['parent']); - request.parent = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.CollectUserEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.api.HttpBody() - ); - client.innerApiCalls.collectUserEvent = stubSimpleCall(expectedResponse); - const [response] = await client.collectUserEvent(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.CollectUserEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.CollectUserEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.collectUserEvent = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.collectUserEvent(request), expectedError); - const actualRequest = (client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.CollectUserEventRequest', ['parent']); - request.parent = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.PurgeUserEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.purgeUserEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeUserEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.PurgeUserEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.purgeUserEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeUserEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.PurgeUserEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.purgeUserEvents = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.purgeUserEvents(request), expectedError); - const actualRequest = (client.innerApiCalls.purgeUserEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeUserEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.PurgeUserEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.purgeUserEvents = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.purgeUserEvents(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.purgeUserEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeUserEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ImportUserEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ImportUserEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ImportUserEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importUserEvents = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importUserEvents(request), expectedError); - const actualRequest = (client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.ImportUserEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importUserEvents = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importUserEvents(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.RejoinUserEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.rejoinUserEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rejoinUserEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.RejoinUserEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.rejoinUserEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rejoinUserEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.RejoinUserEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.rejoinUserEvents(request), expectedError); - const actualRequest = (client.innerApiCalls.rejoinUserEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rejoinUserEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2.RejoinUserEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.rejoinUserEvents(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.rejoinUserEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rejoinUserEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('attributesConfig', () => { - const fakePath = "/rendered/path/attributesConfig"; - 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.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.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('completionConfig', () => { - const fakePath = "/rendered/path/completionConfig"; - 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.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.v2.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('model', () => { - const fakePath = "/rendered/path/model"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - model: "modelValue", - }; - const client = new usereventserviceModule.v2.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.modelPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.modelPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('modelPath', () => { - const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.modelPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromModelName', () => { - const result = client.matchProjectFromModelName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromModelName', () => { - const result = client.matchLocationFromModelName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromModelName', () => { - const result = client.matchCatalogFromModelName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchModelFromModelName', () => { - const result = client.matchModelFromModelName(fakePath); - assert.strictEqual(result, "modelValue"); - assert((client.pathTemplates.modelPathTemplate.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)); - }); - }); - - describe('servingConfig', () => { - const fakePath = "/rendered/path/servingConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - serving_config: "servingConfigValue", - }; - const client = new usereventserviceModule.v2.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/google-cloud-retail/v2/tsconfig.json b/owl-bot-staging/google-cloud-retail/v2/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2/webpack.config.js b/owl-bot-staging/google-cloud-retail/v2/webpack.config.js deleted file mode 100644 index f2c58f2530c..00000000000 --- a/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2alpha/.eslintignore b/owl-bot-staging/google-cloud-retail/v2alpha/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/.eslintrc.json b/owl-bot-staging/google-cloud-retail/v2alpha/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/.gitignore b/owl-bot-staging/google-cloud-retail/v2alpha/.gitignore deleted file mode 100644 index d4f03a0df2e..00000000000 --- a/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2alpha/.jsdoc.js b/owl-bot-staging/google-cloud-retail/v2alpha/.jsdoc.js deleted file mode 100644 index 66e9db869e8..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/.jsdoc.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file 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 2023 Google LLC', - includeDate: false, - sourceFiles: false, - systemName: '@google-cloud/retail', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/.mocharc.js b/owl-bot-staging/google-cloud-retail/v2alpha/.mocharc.js deleted file mode 100644 index 1a38f257db7..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/.mocharc.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -const config = { - "enable-source-maps": true, - "throw-deprecation": true, - "timeout": 10000 -} -if (process.env.MOCHA_THROW_DEPRECATION === 'false') { - delete config['throw-deprecation']; -} -if (process.env.MOCHA_REPORTER) { - config.reporter = process.env.MOCHA_REPORTER; -} -if (process.env.MOCHA_REPORTER_OUTPUT) { - config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; -} -module.exports = config diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/.prettierrc.js b/owl-bot-staging/google-cloud-retail/v2alpha/.prettierrc.js deleted file mode 100644 index 55639e70f9e..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/.prettierrc.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -module.exports = { - ...require('gts/.prettierrc.json') -} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/README.md b/owl-bot-staging/google-cloud-retail/v2alpha/README.md deleted file mode 100644 index 822c4573817..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/README.md +++ /dev/null @@ -1 +0,0 @@ -Retail: Nodejs Client diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/linkinator.config.json b/owl-bot-staging/google-cloud-retail/v2alpha/linkinator.config.json deleted file mode 100644 index befd23c8633..00000000000 --- a/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2alpha/package.json b/owl-bot-staging/google-cloud-retail/v2alpha/package.json deleted file mode 100644 index 0e5702137b8..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/package.json +++ /dev/null @@ -1,73 +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", - "merchant center account link service", - "model service", - "prediction service", - "product service", - "search service", - "serving config service", - "user event service" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^3.5.7" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.1", - "jsdoc": "^4.0.0", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.1", - "linkinator": "^4.1.2", - "mocha": "^10.2.0", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.0.1", - "ts-loader": "^8.4.0", - "typescript": "^4.8.4", - "webpack": "^4.46.0", - "webpack-cli": "^4.10.0" - }, - "engines": { - "node": ">=v12" - } -} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/catalog.proto b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/catalog.proto deleted file mode 100644 index ee569f9c8d7..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/catalog.proto +++ /dev/null @@ -1,477 +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 = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; -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` (incompatible with Retail Search): 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 [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.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 [Product - // levels](https://cloud.google.com/retail/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. - 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. - 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. - SEARCHABLE_OPTION_UNSPECIFIED = 0; - - // Searchable option enabled for an attribute. - SEARCHABLE_ENABLED = 1; - - // Searchable option disabled for an attribute. - SEARCHABLE_DISABLED = 2; - } - - // The status of the exact-searchable option of a catalog attribute. - enum ExactSearchableOption { - // Value used when unset. - EXACT_SEARCHABLE_OPTION_UNSPECIFIED = 0; - - // Exact searchable option enabled for an attribute. - EXACT_SEARCHABLE_ENABLED = 1; - - // Exact searchable option disabled for an attribute. - EXACT_SEARCHABLE_DISABLED = 2; - } - - // The status of the retrievable option of a catalog attribute. - enum RetrievableOption { - // Value used when unset. - RETRIEVABLE_OPTION_UNSPECIFIED = 0; - - // Retrievable option enabled for an attribute. - RETRIEVABLE_ENABLED = 1; - - // Retrievable option disabled for an attribute. - RETRIEVABLE_DISABLED = 2; - } - - // Required. Attribute name. - // For example: `color`, `brands`, `attributes.custom_attribute`, such as - // `attributes.xyz`. - // To be indexable, the attribute name can contain only alpha-numeric - // characters and underscores. For example, an attribute named - // `attributes.abc_xyz` can be indexed, but an attribute named - // `attributes.abc-xyz` cannot be indexed. - // - // If the attribute key starts with `attributes.`, then the attribute is a - // custom attribute. Attributes such as `brands`, `patterns`, and `title` are - // built-in and called system attributes. - 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 - // [CatalogService.AddCatalogAttribute][google.cloud.retail.v2alpha.CatalogService.AddCatalogAttribute], - // [CatalogService.ImportCatalogAttributes][google.cloud.retail.v2alpha.CatalogService.ImportCatalogAttributes], - // or - // [CatalogService.UpdateAttributesConfig][google.cloud.retail.v2alpha.CatalogService.UpdateAttributesConfig] - // APIs. This field is `False` for pre-loaded - // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute]s. - // - // Only pre-loaded [catalog - // attributes][google.cloud.retail.v2alpha.CatalogAttribute] that are neither - // in use by products nor predefined can be deleted. [Catalog - // attributes][google.cloud.retail.v2alpha.CatalogAttribute] that are - // either in use by products or are predefined attributes 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]. - // - // Must be specified, otherwise throws INVALID_FORMAT error. - 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. - // - // Must be specified, otherwise throws INVALID_FORMAT error. - 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. - // - // Must be specified, otherwise throws INVALID_FORMAT error. - SearchableOption searchable_option = 7; - - // When - // [AttributesConfig.attribute_config_level][google.cloud.retail.v2alpha.AttributesConfig.attribute_config_level] - // is CATALOG_LEVEL_ATTRIBUTE_CONFIG, if RECOMMENDATIONS_FILTERING_ENABLED, - // attribute values are filterable for recommendations. - // This option works for categorical features only, - // does not work for numerical features, inventory filtering. - RecommendationsFilteringOption recommendations_filtering_option = 8; - - // If EXACT_SEARCHABLE_ENABLED, attribute values will be exact searchable. - // This property only applies to textual custom attributes and requires - // indexable set to enabled to enable exact-searchable. If unset, the server - // behavior defaults to - // [EXACT_SEARCHABLE_DISABLED][google.cloud.retail.v2alpha.CatalogAttribute.ExactSearchableOption.EXACT_SEARCHABLE_DISABLED]. - ExactSearchableOption exact_searchable_option = 11; - - // If RETRIEVABLE_ENABLED, attribute values are retrievable in the search - // results. If unset, the server behavior defaults to - // [RETRIEVABLE_DISABLED][google.cloud.retail.v2alpha.CatalogAttribute.RetrievableOption.RETRIEVABLE_DISABLED]. - RetrievableOption retrievable_option = 12; -} - -// 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. Default - // value is 20. If left unset or set to 0, then will fallback to default - // value. - // - // Value range is 1 to 20. - 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. - // - // Value range is 1 to 20. - 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 source data for the latest import of the autocomplete - // suggestion phrases. - 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 source data for the latest import of the autocomplete - // denylist phrases. - CompletionDataInputConfig denylist_input_config = 7 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Name of the 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 source data for the latest import of the autocomplete - // allowlist phrases. - CompletionDataInputConfig allowlist_input_config = 9 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Name of the 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 is given in [Included - // destination](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; - - // Criteria for the Merchant Center feeds to be ingested via the link. - // All offers will be ingested if the list is empty. - // Otherwise the offers will be ingested from selected feeds. - repeated MerchantCenterFeedFilter feeds = 6; -} - -// Merchant Center Feed filter criterion. -message MerchantCenterFeedFilter { - // Merchant Center primary feed ID. - int64 primary_feed_id = 1; - - // Merchant Center primary feed name. The name is used for the display - // purposes only. - string primary_feed_name = 2; -} - -// 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/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/catalog_service.proto b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/catalog_service.proto deleted file mode 100644 index 41b1af8a3ac..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/catalog_service.proto +++ /dev/null @@ -1,527 +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 = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; -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: "*" - }; - } - - // Removes all specified - // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute]s from the - // [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig]. - rpc BatchRemoveCatalogAttributes(BatchRemoveCatalogAttributesRequest) - returns (BatchRemoveCatalogAttributesResponse) { - option (google.api.http) = { - post: "/v2alpha/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:batchRemoveCatalogAttributes" - 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.BatchRemoveCatalogAttributes][google.cloud.retail.v2alpha.CatalogService.BatchRemoveCatalogAttributes] -// method. -message BatchRemoveCatalogAttributesRequest { - // Required. The attributes config resource shared by all catalog attributes - // being deleted. 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 keys of the - // [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute]s to - // delete. A maximum of 1000 catalog attributes can be deleted in a batch. - repeated string attribute_keys = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Response of the -// [CatalogService.BatchRemoveCatalogAttributes][google.cloud.retail.v2alpha.CatalogService.BatchRemoveCatalogAttributes]. -message BatchRemoveCatalogAttributesResponse { - // Catalog attributes that were deleted. Only pre-loaded [catalog - // attributes][google.cloud.retail.v2alpha.CatalogAttribute] that are - // neither [in - // use][google.cloud.retail.v2alpha.CatalogAttribute.in_use] by - // products nor predefined can be deleted. - repeated string deleted_catalog_attributes = 1; - - // Catalog attributes that were reset. [Catalog - // attributes][google.cloud.retail.v2alpha.CatalogAttribute] that are either - // [in use][google.cloud.retail.v2alpha.CatalogAttribute.in_use] by products - // or are predefined attributes cannot be deleted; however, their - // configuration properties will reset to default values upon removal request. - repeated string reset_catalog_attributes = 2; -} - -// 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/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/common.proto b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/common.proto deleted file mode 100644 index 276af73c9d2..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/common.proto +++ /dev/null @@ -1,794 +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 = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; -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. In this case, server behavior 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; -} - -// If filtering for recommendations is enabled. -enum RecommendationsFilteringOption { - // Value used when unset. - // In this case, server behavior defaults to - // [RECOMMENDATIONS_FILTERING_DISABLED][google.cloud.retail.v2alpha.RecommendationsFilteringOption.RECOMMENDATIONS_FILTERING_DISABLED]. - RECOMMENDATIONS_FILTERING_OPTION_UNSPECIFIED = 0; - - // Recommendation filtering is disabled. - RECOMMENDATIONS_FILTERING_DISABLED = 1; - - // Recommendation filtering is enabled. - RECOMMENDATIONS_FILTERING_ENABLED = 3; -} - -// The use case of Cloud Retail Search. -enum SearchSolutionUseCase { - // The value when it's unspecified. In this case, server behavior defaults to - // [SEARCH_SOLUTION_USE_CASE_SEARCH][google.cloud.retail.v2alpha.SearchSolutionUseCase.SEARCH_SOLUTION_USE_CASE_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. - // For example, "a b c" is 3 terms and allowed, but " a b c d" is 4 terms - // and not allowed for a 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 rules only work for [controls][google.cloud.retail.v2alpha.Control] -// with -// [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2alpha.SolutionType.SOLUTION_TYPE_SEARCH]. -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][google.cloud.retail.v2alpha.Condition.query_terms] - // provided is a global match. - // - 1 or more - // [Condition.query_terms][google.cloud.retail.v2alpha.Condition.query_terms] - // provided are combined with OR operator. - // * Action Input: The request query and filter that are 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][google.cloud.retail.v2alpha.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 75 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 is normally ignored unless - // [AttributesConfig.attribute_config_level][google.cloud.retail.v2alpha.AttributesConfig.attribute_config_level] - // of the [Catalog][google.cloud.retail.v2alpha.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.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 [deprecated = true]; - - // This field is normally ignored unless - // [AttributesConfig.attribute_config_level][google.cloud.retail.v2alpha.AttributesConfig.attribute_config_level] - // of the [Catalog][google.cloud.retail.v2alpha.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.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 [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.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 not be larger than 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. - // 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]. If set, - // [original_price][google.cloud.retail.v2alpha.PriceInfo.original_price] - // should be greater than or equal to - // [price][google.cloud.retail.v2alpha.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.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. 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.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/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/completion_service.proto b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/completion_service.proto deleted file mode 100644 index 61cd99363e3..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/completion_service.proto +++ /dev/null @@ -1,255 +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/search_service.proto"; -import "google/longrunning/operations.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; -option go_package = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; -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"; - -// Autocomplete service for retail. -// -// This feature is only available for users who have Retail Search enabled. -// 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. - // 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. - // 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" - }; - } -} - -// Autocomplete 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; - - // Note that this field applies for `user-data` dataset only. For requests - // with `cloud-retail` dataset, setting this field has no effect. - // - // 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. We recommend that you - // leave this field empty. - // - // It can 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 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][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; - - // If true, attribute suggestions are enabled and provided in response. - // - // This field is only available for "cloud-retail" dataset. - bool enable_attribute_suggestions = 9; - - // The entity for customers that may run multiple different entities, domains, - // sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, - // `google.com`, `youtube.com`, etc. - // If this is set, it should be exactly matched with - // [UserEvent.entity][google.cloud.retail.v2alpha.UserEvent.entity] to get - // per-entity autocomplete results. - string entity = 10; -} - -// Response of the autocomplete 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. It requires - // [UserEvent.product_details][google.cloud.retail.v2alpha.UserEvent.product_details] - // is imported properly. - map attributes = 2; - - // Facet information for the suggestion term. Gives the number of items - // resulting from a search with this suggestion term for each facet. - // - // This is an experimental feature for limited customers. Please reach out - // to the support team if you would like to receive this information. - repeated SearchResponse.Facet facets = 3; - - // Total number of products associated with a search with this suggestion. - // - // This is an experimental feature for limited customers. Please reach out - // to the support team if you would like to receive this information. - int32 total_product_count = 4; - } - - // Recent search of this user. - message RecentSearchResult { - // The recent search query. - string recent_search = 1; - } - - // Resource that represents attribute results. - message AttributeResult { - // The list of suggestions for the attribute. - repeated string suggestions = 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 case. - // - // * They are UTF-8 safe. - // - // Recent searches are deduplicated. More recent searches will be reserved - // when duplication happens. - repeated RecentSearchResult recent_search_results = 3; - - // A map of matched attribute suggestions. This field is only available for - // "cloud-retail" dataset. - // - // Current supported keys: - // - // * `brands` - // - // * `categories` - map attribute_results = 4; -} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/control.proto b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/control.proto deleted file mode 100644 index 5c3047ce438..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/control.proto +++ /dev/null @@ -1,100 +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 = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; -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 metadata that can be linked to a -// [ServingConfig][google.cloud.retail.v2alpha.ServingConfig] and affect search -// or recommendation results at serving time. -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. - // - // Note that this field is deprecated and will throw NOT_IMPLEMENTED if - // used for creating a control. - SearchRequest.FacetSpec facet_spec = 3 [deprecated = true]; - - // 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 - // config][google.cloud.retail.v2alpha.ServingConfig] ids that are associated - // with this control in the same - // [Catalog][google.cloud.retail.v2alpha.Catalog]. - // - // Note the association is managed via the - // [ServingConfig][google.cloud.retail.v2alpha.ServingConfig], this is an - // output only denormalized view. - repeated string associated_serving_config_ids = 5 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Required. Immutable. The solution types that the control 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][google.cloud.retail.v2alpha.SolutionType.SOLUTION_TYPE_SEARCH]. - repeated SolutionType solution_types = 6 [ - (google.api.field_behavior) = REQUIRED, - (google.api.field_behavior) = IMMUTABLE - ]; - - // 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][google.cloud.retail.v2alpha.SearchSolutionUseCase.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; -} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/control_service.proto b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/control_service.proto deleted file mode 100644 index 7cfd462db97..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/control_service.proto +++ /dev/null @@ -1,185 +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 = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; -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 update 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 by their parent - // [Catalog][google.cloud.retail.v2alpha.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 get. 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/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/export_config.proto b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/export_config.proto deleted file mode 100644 index 40ceb9cdb3b..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/export_config.proto +++ /dev/null @@ -1,107 +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 = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; -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 is -// 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; - - // This field is never set. - ExportErrorsConfig errors_config = 2; - - // Output result indicating where the data were exported to. - OutputResult output_result = 3; -} - -// 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; - - // This field is never set. - ExportErrorsConfig errors_config = 2; - - // Output result indicating where the data were exported to. - OutputResult output_result = 3; -} - -// Output result that stores the information about where the exported data is -// stored. -message OutputResult { - // The BigQuery location where the result is stored. - repeated BigQueryOutputResult bigquery_result = 1; - - // The Google Cloud Storage location where the result is stored. - repeated GcsOutputResult gcs_result = 2; -} - -// A BigQuery output result. -message BigQueryOutputResult { - // The ID of a BigQuery Dataset. - string dataset_id = 1; - - // The ID of a BigQuery Table. - string table_id = 2; -} - -// A Gcs output result. -message GcsOutputResult { - // The uri of Gcs output - string output_uri = 1; -} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/import_config.proto b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/import_config.proto deleted file mode 100644 index 77ab88be3ef..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/import_config.proto +++ /dev/null @@ -1,408 +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 = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; -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. -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 in - // [ImportProductsRequest][google.cloud.retail.v2alpha.ImportProductsRequest]. - 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`: - // The schema is available here: - // https://support.google.com/analytics/answer/7029846. - // - // Supported values for autocomplete 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 are 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. - 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, all fields are updated. - 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; - - // Full Pub/Sub topic name for receiving notification. If this field is set, - // when the import is finished, a notification is sent to - // specified Pub/Sub topic. The message data is 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.v2alpha.ImportProductsRequest.parent]. - // Make sure that `service-@gcp-sa-retail.iam.gserviceaccount.com` has the - // `pubsub.topics.publish` IAM permission on the topic. - string notification_pubsub_topic = 7; - - // If true, this performs the FULL import even if it would delete a large - // proportion of the products in the default branch, which could potentially - // cause outages if you have live predict/search traffic. - // - // Only supported when - // [ImportProductsRequest.reconciliation_mode][google.cloud.retail.v2alpha.ImportProductsRequest.reconciliation_mode] - // is set to `FULL`. - bool skip_default_branch_protection = 8; -} - -// 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 is sent to - // specified Pub/Sub topic. The message data is 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 is -// 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 is sent to - // specified Pub/Sub topic. The message data is JSON string of a - // [Operation][google.longrunning.Operation]. - // Format of the Pub/Sub topic is `projects/{project}/topics/{topic}`. - string notification_pubsub_topic = 6; - - // Metadata related to transform user events. - TransformedUserEventsMetadata transformed_user_events_metadata = 7; -} - -// Metadata related to transform user events operation. -message TransformedUserEventsMetadata { - // Count of entries in the source user events BigQuery table. - int64 source_events_count = 1; - - // Count of entries in the transformed user events BigQuery table, which could - // be different from the actually imported number of user events. - int64 transformed_events_count = 2; -} - -// 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/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/merchant_center_account_link.proto b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/merchant_center_account_link.proto deleted file mode 100644 index 5d8df7c8ab3..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/merchant_center_account_link.proto +++ /dev/null @@ -1,137 +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 = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; -option java_multiple_files = true; -option java_outer_classname = "MerchantCenterAccountLinkProto"; -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"; - -// 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 MerchantCenterAccountLink { - option (google.api.resource) = { - type: "retail.googleapis.com/MerchantCenterAccountLink" - pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/merchantCenterAccountLinks/{merchant_center_account_link}" - }; - - // Merchant Center Feed filter criterion. - message MerchantCenterFeedFilter { - // Merchant Center primary feed ID. - int64 primary_feed_id = 1; - - // Merchant Center primary feed name. The name is used for the display - // purposes only. - string primary_feed_name = 2; - } - - // The state of the link. - enum State { - // Default value. - STATE_UNSPECIFIED = 0; - - // Link is created and LRO is not complete. - PENDING = 1; - - // Link is active. - ACTIVE = 2; - - // Link creation failed. - FAILED = 3; - } - - // Output only. Immutable. Full resource name of the Merchant Center Account - // Link, such as - // `projects/*/locations/global/catalogs/default_catalog/merchantCenterAccountLinks/merchant_center_account_link`. - string name = 1 [ - (google.api.field_behavior) = IMMUTABLE, - (google.api.field_behavior) = OUTPUT_ONLY - ]; - - // Output only. Immutable. - // [MerchantCenterAccountLink][google.cloud.retail.v2alpha.MerchantCenterAccountLink] - // identifier, which is the final component of - // [name][google.cloud.retail.v2alpha.MerchantCenterAccountLink.name]. This - // field is auto generated and follows the convention: - // `BranchId_MerchantCenterAccountId`. - // `projects/*/locations/global/catalogs/default_catalog/merchantCenterAccountLinks/id_1`. - string id = 8 [ - (google.api.field_behavior) = IMMUTABLE, - (google.api.field_behavior) = OUTPUT_ONLY - ]; - - // 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 = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The branch id (e.g. 0/1/2) within the 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 = 3 [(google.api.field_behavior) = REQUIRED]; - - // The FeedLabel used to perform filtering. - // Note: this replaces - // [region_id](https://developers.google.com/shopping-content/reference/rest/v2.1/products#Product.FIELDS.feed_label). - // - // Example value: `US`. - // Example value: `FeedLabel1`. - string feed_label = 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; - - // Criteria for the Merchant Center feeds to be ingested via the link. - // All offers will be ingested if the list is empty. - // Otherwise the offers will be ingested from selected feeds. - repeated MerchantCenterFeedFilter feed_filters = 6; - - // Output only. Represents the state of the link. - State state = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. GCP project ID. - string project_id = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// Common metadata related to the progress of the operations. -message CreateMerchantCenterAccountLinkMetadata { - // 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; -} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/merchant_center_account_link_service.proto b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/merchant_center_account_link_service.proto deleted file mode 100644 index 93704f004c8..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/merchant_center_account_link_service.proto +++ /dev/null @@ -1,140 +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/merchant_center_account_link.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/empty.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; -option go_package = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; -option java_multiple_files = true; -option java_outer_classname = "MerchantCenterAccountLinkServiceProto"; -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"; - -// Merchant Center Link service to link a Branch to a Merchant Center Account. -service MerchantCenterAccountLinkService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Lists all - // [MerchantCenterAccountLink][google.cloud.retail.v2alpha.MerchantCenterAccountLink]s - // under the specified parent [Catalog][google.cloud.retail.v2alpha.Catalog]. - rpc ListMerchantCenterAccountLinks(ListMerchantCenterAccountLinksRequest) - returns (ListMerchantCenterAccountLinksResponse) { - option (google.api.http) = { - get: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/merchantCenterAccountLinks" - }; - option (google.api.method_signature) = "parent"; - } - - // Creates a - // [MerchantCenterAccountLink][google.cloud.retail.v2alpha.MerchantCenterAccountLink]. - rpc CreateMerchantCenterAccountLink(CreateMerchantCenterAccountLinkRequest) - returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/merchantCenterAccountLinks" - body: "merchant_center_account_link" - }; - option (google.api.method_signature) = - "parent,merchant_center_account_link"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2alpha.MerchantCenterAccountLink" - metadata_type: "google.cloud.retail.v2alpha.CreateMerchantCenterAccountLinkMetadata" - }; - } - - // Deletes a - // [MerchantCenterAccountLink][google.cloud.retail.v2alpha.MerchantCenterAccountLink]. - // If the - // [MerchantCenterAccountLink][google.cloud.retail.v2alpha.MerchantCenterAccountLink] - // to delete does not exist, a NOT_FOUND error is returned. - rpc DeleteMerchantCenterAccountLink(DeleteMerchantCenterAccountLinkRequest) - returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v2alpha/{name=projects/*/locations/*/catalogs/*/merchantCenterAccountLinks/*}" - }; - option (google.api.method_signature) = "name"; - } -} - -// Request for -// [MerchantCenterAccountLinkService.ListMerchantCenterAccountLinks][google.cloud.retail.v2alpha.MerchantCenterAccountLinkService.ListMerchantCenterAccountLinks] -// method. -message ListMerchantCenterAccountLinksRequest { - // Required. The parent Catalog of the resource. - // It must match this format: - // projects/{PROJECT_NUMBER}/locations/global/catalogs/{CATALOG_ID} - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; -} - -// Response for -// [MerchantCenterAccountLinkService.ListMerchantCenterAccountLinks][google.cloud.retail.v2alpha.MerchantCenterAccountLinkService.ListMerchantCenterAccountLinks] -// method. -message ListMerchantCenterAccountLinksResponse { - // The links. - repeated MerchantCenterAccountLink merchant_center_account_links = 1; -} - -// Request for -// [MerchantCenterAccountLinkService.CreateMerchantCenterAccountLink][google.cloud.retail.v2alpha.MerchantCenterAccountLinkService.CreateMerchantCenterAccountLink] -// method. -message CreateMerchantCenterAccountLinkRequest { - // Required. The branch resource where this MerchantCenterAccountLink will be - // created. Format: - // projects/{PROJECT_NUMBER}/locations/global/catalogs/{CATALOG_ID}} - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Catalog" } - ]; - - // Required. The - // [MerchantCenterAccountLink][google.cloud.retail.v2alpha.MerchantCenterAccountLink] - // to create. - // - // If the caller does not have permission to create the - // [MerchantCenterAccountLink][google.cloud.retail.v2alpha.MerchantCenterAccountLink], - // regardless of whether or not it exists, a PERMISSION_DENIED error is - // returned. - MerchantCenterAccountLink merchant_center_account_link = 2 - [(google.api.field_behavior) = REQUIRED]; -} - -// Request for -// [MerchantCenterAccountLinkService.DeleteMerchantCenterAccountLink][google.cloud.retail.v2alpha.MerchantCenterAccountLinkService.DeleteMerchantCenterAccountLink] -// method. -message DeleteMerchantCenterAccountLinkRequest { - // Required. Full resource name. Format: - // projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/merchantCenterAccountLinks/{merchant_center_account_link_id} - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "retail.googleapis.com/MerchantCenterAccountLink" - } - ]; -} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/model.proto b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/model.proto deleted file mode 100644 index b8f8cd8dcf8..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/model.proto +++ /dev/null @@ -1,451 +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/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; -option go_package = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; -option java_multiple_files = true; -option java_outer_classname = "ModelProto"; -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 that describes the training and serving parameters of a -// [Model][google.cloud.retail.v2alpha.Model]. A -// [Model][google.cloud.retail.v2alpha.Model] can be associated with a -// [ServingConfig][google.cloud.retail.v2alpha.ServingConfig] and then queried -// through the Predict API. -message Model { - option (google.api.resource) = { - type: "retail.googleapis.com/Model" - pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}" - }; - - // The PageOptimizationConfig for model training. - // - // This determines how many panels to optimize for, and which serving - // configs to consider for each panel. - // The purpose of this model is to optimize which - // [ServingConfig][google.cloud.retail.v2alpha.ServingConfig] to show on which - // panels in way that optimizes the visitors shopping journey. - message PageOptimizationConfig { - // A candidate to consider for a given panel. Currently only - // [ServingConfig][google.cloud.retail.v2alpha.ServingConfig] are valid - // candidates. - message Candidate { - oneof candidate { - // This has to be a valid - // [ServingConfig][google.cloud.retail.v2alpha.ServingConfig] - // identifier. For example, for a ServingConfig with full name: - // `projects/*/locations/global/catalogs/default_catalog/servingConfigs/my_candidate_config`, - // this would be `my_candidate_config`. - string serving_config_id = 1; - } - } - - // An individual panel with a list of - // [ServingConfigs][google.cloud.retail.v2alpha.ServingConfig] to consider - // for it. - message Panel { - // Optional. The name to display for the panel. - string display_name = 1 [(google.api.field_behavior) = OPTIONAL]; - - // Required. The candidates to consider on the panel. - repeated Candidate candidates = 2 - [(google.api.field_behavior) = REQUIRED]; - - // Required. The default candidate. If the model fails at serving time, - // we fall back to the default. - Candidate default_candidate = 3 [(google.api.field_behavior) = REQUIRED]; - } - - // Restrictions of expected returned results. - enum Restriction { - // Unspecified value for restriction. - RESTRICTION_UNSPECIFIED = 0; - - // Allow any [ServingConfig][google.cloud.retail.v2alpha.ServingConfig] to - // be show on any number of panels. - // - // Example: - // - // `Panel1 candidates`: pdp_ctr, pdp_cvr, home_page_ctr_no_diversity - // - // `Panel2 candidates`: home_page_ctr_no_diversity, - // home_page_ctr_diversity, - // pdp_cvr_no_diversity - // - // `Restriction` = NO_RESTRICTION - // - // `Valid combinations`: - // - // * (pdp_ctr, home_page_ctr_no_diversity) - // * (pdp_ctr, home_page_ctr_diversity) - // * (pdp_ctr, pdp_cvr_no_diversity) - // * (pdp_cvr, home_page_ctr_no_diversity) - // * (pdp_cvr, home_page_ctr_diversity) - // * (pdp_cvr, pdp_cvr_no_diversity) - // * (home_page_ctr_no_diversity, home_page_ctr_no_diversity) - // * (home_page_ctr_no_diversity, home_page_ctr_diversity) - // * (home_page_ctr_no_diversity, pdp_cvr_no_diversity) - // - // `Invalid combinations`: [] - NO_RESTRICTION = 1; - - // Do not allow the same - // [ServingConfig.name][google.cloud.retail.v2alpha.ServingConfig.name] to - // be shown on multiple panels. - // - // Example: - // - // `Panel1 candidates`: pdp_ctr, pdp_cvr, home_page_ctr_no_diversity - // - // - // `Panel2 candidates`: home_page_ctr_no_diversity, - // home_page_ctr_diversity_low, - // pdp_cvr_no_diversity - // - // `Restriction` = `UNIQUE_SERVING_CONFIG_RESTRICTION` - // - // `Valid combinations`: - // - // * (pdp_ctr, home_page_ctr_no_diversity) - // * (pdp_ctr, home_page_ctr_diversity_low) - // * (pdp_ctr, pdp_cvr_no_diversity) - // * (pdp_ctr, pdp_cvr_no_diversity) - // * (pdp_cvr, home_page_ctr_no_diversity) - // * (pdp_cvr, home_page_ctr_diversity_low) - // * (pdp_cvr, pdp_cvr_no_diversity) - // * (home_page_ctr_no_diversity, home_page_ctr_diversity_low) - // * (home_page_ctr_no_diversity, pdp_cvr_no_diversity) - // - // `Invalid combinations`: - // - // * (home_page_ctr_no_diversity, home_page_ctr_no_diversity) - UNIQUE_SERVING_CONFIG_RESTRICTION = 2; - - // Do not allow multiple - // [ServingConfigs][google.cloud.retail.v2alpha.ServingConfig] with same - // [Model.name][google.cloud.retail.v2alpha.Model.name] to be show on on - // different panels. - // - // Example: - // - // `Panel1 candidates`: pdp_ctr, pdp_cvr, home_page_ctr_no_diversity - // - // - // `Panel2 candidates`: home_page_ctr_no_diversity, - // home_page_ctr_diversity_low, - // pdp_cvr_no_diversity - // - // `Restriction` = `UNIQUE_MODEL_RESTRICTION` - // - // `Valid combinations`: - // - // * (pdp_ctr, home_page_ctr_no_diversity) - // * (pdp_ctr, home_page_ctr_diversity) - // * (pdp_ctr, pdp_cvr_no_diversity) - // * (pdp_ctr, pdp_cvr_no_diversity) - // * (pdp_cvr, home_page_ctr_no_diversity) - // * (pdp_cvr, home_page_ctr_diversity_low) - // * (home_page_ctr_no_diversity, pdp_cvr_no_diversity) - // - // `Invalid combinations`: - // - // * (home_page_ctr_no_diversity, home_page_ctr_no_diversity) - // * (pdp_cvr, pdp_cvr_no_diversity) - UNIQUE_MODEL_RESTRICTION = 3; - - // Do not allow multiple - // [ServingConfigs][google.cloud.retail.v2alpha.ServingConfig] with same - // [Model.type][google.cloud.retail.v2alpha.Model.type] to be shown on - // different panels. - // - // Example: - // - // `Panel1 candidates`: pdp_ctr, pdp_cvr, home_page_ctr_no_diversity - // - // - // `Panel2 candidates`: home_page_ctr_no_diversity, - // home_page_ctr_diversity_low, - // pdp_cvr_no_diversity - // - // `Restriction` = `UNIQUE_MODEL_RESTRICTION` - // - // `Valid combinations`: - // - // * (pdp_ctr, home_page_ctr_no_diversity) - // * (pdp_ctr, home_page_ctr_diversity) - // * (pdp_cvr, home_page_ctr_no_diversity) - // * (pdp_cvr, home_page_ctr_diversity_low) - // * (home_page_ctr_no_diversity, pdp_cvr_no_diversity) - // - // `Invalid combinations`: - // - // * (pdp_ctr, pdp_cvr_no_diversity) - // * (pdp_ctr, pdp_cvr_no_diversity) - // * (pdp_cvr, pdp_cvr_no_diversity) - // * (home_page_ctr_no_diversity, home_page_ctr_no_diversity) - // * (home_page_ctr_no_diversity, home_page_ctr_diversity) - UNIQUE_MODEL_TYPE_RESTRICTION = 4; - } - - // Required. The type of [UserEvent][google.cloud.retail.v2alpha.UserEvent] - // this page optimization is shown for. - // - // Each page has an associated event type - this will be the - // corresponding event type for the page that the page optimization - // model is used on. - // - // Supported types: - // - // * `add-to-cart`: Products being added to cart. - // * `detail-page-view`: Products detail page viewed. - // * `home-page-view`: Homepage viewed - // * `category-page-view`: Homepage viewed - // * `shopping-cart-page-view`: User viewing a shopping cart. - // - // `home-page-view` only allows models with type `recommended-for-you`. - // All other page_optimization_event_type allow all - // [Model.types][google.cloud.retail.v2alpha.Model.type]. - string page_optimization_event_type = 1 - [(google.api.field_behavior) = REQUIRED]; - - // Required. A list of panel configurations. - // - // Limit = 5. - repeated Panel panels = 2 [(google.api.field_behavior) = REQUIRED]; - - // Optional. How to restrict results across panels e.g. can the same - // [ServingConfig][google.cloud.retail.v2alpha.ServingConfig] be shown on - // multiple panels at once. - // - // If unspecified, default to `UNIQUE_MODEL_RESTRICTION`. - Restriction restriction = 3 [(google.api.field_behavior) = OPTIONAL]; - } - - // Represents an ordered combination of valid serving configs, which - // can be used for `PAGE_OPTIMIZATION` recommendations. - message ServingConfigList { - // Optional. A set of valid serving configs that may be used for - // `PAGE_OPTIMIZATION`. - repeated string serving_config_ids = 1 - [(google.api.field_behavior) = OPTIONAL]; - } - - // The serving state of the model. - enum ServingState { - // Unspecified serving state. - SERVING_STATE_UNSPECIFIED = 0; - - // The model is not serving. - INACTIVE = 1; - - // The model is serving and can be queried. - ACTIVE = 2; - - // The model is trained on tuned hyperparameters and can be - // queried. - TUNED = 3; - } - - // The training state of the model. - enum TrainingState { - // Unspecified training state. - TRAINING_STATE_UNSPECIFIED = 0; - - // The model training is paused. - PAUSED = 1; - - // The model is training. - TRAINING = 2; - } - - // Describes whether periodic tuning is enabled for this model - // or not. Periodic tuning is scheduled at most every three months. You can - // start a tuning process manually by using the `TuneModel` - // method, which starts a tuning process immediately and resets the quarterly - // schedule. Enabling or disabling periodic tuning does not affect any - // current tuning processes. - enum PeriodicTuningState { - // Unspecified default value, should never be explicitly set. - PERIODIC_TUNING_STATE_UNSPECIFIED = 0; - - // The model has periodic tuning disabled. Tuning - // can be reenabled by calling the `EnableModelPeriodicTuning` - // method or by calling the `TuneModel` method. - PERIODIC_TUNING_DISABLED = 1; - - // The model cannot be tuned with periodic tuning OR the - // `TuneModel` method. Hide the options in customer UI and - // reject any requests through the backend self serve API. - ALL_TUNING_DISABLED = 3; - - // The model has periodic tuning enabled. Tuning - // can be disabled by calling the `DisableModelPeriodicTuning` - // method. - PERIODIC_TUNING_ENABLED = 2; - } - - // Describes whether this model have sufficient training data - // to be continuously trained. - enum DataState { - // Unspecified default value, should never be explicitly set. - DATA_STATE_UNSPECIFIED = 0; - - // The model has sufficient training data. - DATA_OK = 1; - - // The model does not have sufficient training data. Error - // messages can be queried via Stackdriver. - DATA_ERROR = 2; - } - - // Training configuration specific to a - // [Model.type][google.cloud.retail.v2alpha.Model.type] - currently, only for - // page optimization. - oneof training_config { - // Optional. The page optimization config. - PageOptimizationConfig page_optimization_config = 17 - [(google.api.field_behavior) = OPTIONAL]; - } - - // Required. The fully qualified resource name of the model. - // - // Format: - // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` - // catalog_id has char limit of 50. - // recommendation_model_id has char limit of 40. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The display name of the model. - // - // Should be human readable, used to display Recommendation Models in the - // Retail Cloud Console Dashboard. UTF-8 encoded string with limit of 1024 - // characters. - string display_name = 2 [(google.api.field_behavior) = REQUIRED]; - - // Optional. The training state that the model is in (e.g. - // `TRAINING` or `PAUSED`). - // - // Since part of the cost of running the service - // is frequency of training - this can be used to determine when to train - // model in order to control cost. If not specified: the default value for - // `CreateModel` method is `TRAINING`. The default value for - // `UpdateModel` method is to keep the state the same as before. - TrainingState training_state = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Output only. The serving state of the model: `ACTIVE`, `NOT_ACTIVE`. - ServingState serving_state = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Timestamp the Recommendation Model was created at. - google.protobuf.Timestamp create_time = 5 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Timestamp the Recommendation Model was last updated. E.g. - // if a Recommendation Model was paused - this would be the time the pause was - // initiated. - google.protobuf.Timestamp update_time = 6 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Required. The type of model e.g. `home-page`. - // - // Currently supported values: `recommended-for-you`, `others-you-may-like`, - // `frequently-bought-together`, `page-optimization`, `similar-items`, - // `buy-it-again`, `on-sale-items`, and `recently-viewed`(readonly value). - // - // - // This field together with - // [optimization_objective][google.cloud.retail.v2alpha.Model.optimization_objective] - // describe model metadata to use to control model training and serving. - // See https://cloud.google.com/retail/docs/models - // for more details on what the model metadata control and which combination - // of parameters are valid. For invalid combinations of parameters (e.g. type - // = `frequently-bought-together` and optimization_objective = `ctr`), you - // receive an error 400 if you try to create/update a recommendation with - // this set of knobs. - string type = 7 [(google.api.field_behavior) = REQUIRED]; - - // Optional. The optimization objective e.g. `cvr`. - // - // Currently supported - // values: `ctr`, `cvr`, `revenue-per-order`. - // - // If not specified, we choose default based on model type. - // Default depends on type of recommendation: - // - // `recommended-for-you` => `ctr` - // - // `others-you-may-like` => `ctr` - // - // `frequently-bought-together` => `revenue_per_order` - // - // This field together with - // [optimization_objective][google.cloud.retail.v2alpha.Model.type] - // describe model metadata to use to control model training and serving. - // See https://cloud.google.com/retail/docs/models - // for more details on what the model metadata control and which combination - // of parameters are valid. For invalid combinations of parameters (e.g. type - // = `frequently-bought-together` and optimization_objective = `ctr`), you - // receive an error 400 if you try to create/update a recommendation with - // this set of knobs. - string optimization_objective = 8 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The state of periodic tuning. - // - // The period we use is 3 months - to do a - // one-off tune earlier use the `TuneModel` method. Default value - // is `PERIODIC_TUNING_ENABLED`. - PeriodicTuningState periodic_tuning_state = 11 - [(google.api.field_behavior) = OPTIONAL]; - - // Output only. The timestamp when the latest successful tune finished. - google.protobuf.Timestamp last_tune_time = 12 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The tune operation associated with the model. - // - // Can be used to determine if there is an ongoing tune for this - // recommendation. Empty field implies no tune is goig on. - string tuning_operation = 15 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The state of data requirements for this model: `DATA_OK` and - // `DATA_ERROR`. - // - // Recommendation model cannot be trained if the data is in - // `DATA_ERROR` state. Recommendation model can have `DATA_ERROR` state even - // if serving state is `ACTIVE`: models were trained successfully before, but - // cannot be refreshed because model no longer has sufficient - // data for training. - DataState data_state = 16 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. If `RECOMMENDATIONS_FILTERING_ENABLED`, recommendation filtering - // by attributes is enabled for the model. - RecommendationsFilteringOption filtering_option = 18 - [(google.api.field_behavior) = OPTIONAL]; - - // Output only. The list of valid serving configs associated with the - // PageOptimizationConfig. - repeated ServingConfigList serving_config_lists = 19 - [(google.api.field_behavior) = OUTPUT_ONLY]; -} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/model_service.proto b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/model_service.proto deleted file mode 100644 index e26fc8b4205..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/model_service.proto +++ /dev/null @@ -1,263 +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/model.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; -option go_package = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; -option java_multiple_files = true; -option java_outer_classname = "ModelServiceProto"; -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 performing CRUD operations on models. -// Recommendation models contain all the metadata necessary to generate a set of -// models for the `Predict()` API. A model is queried -// indirectly via a ServingConfig, which associates a model with a -// given Placement (e.g. Frequently Bought Together on Home Page). -// -// This service allows you to do the following: -// -// * Initiate training of a model. -// * Pause training of an existing model. -// * List all the available models along with their metadata. -// * Control their tuning schedule. -service ModelService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Creates a new model. - rpc CreateModel(CreateModelRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/models" - body: "model" - }; - option (google.api.method_signature) = "parent,model"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2alpha.Model" - metadata_type: "google.cloud.retail.v2alpha.CreateModelMetadata" - }; - } - - // Gets a model. - rpc GetModel(GetModelRequest) returns (Model) { - option (google.api.http) = { - get: "/v2alpha/{name=projects/*/locations/*/catalogs/*/models/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Pauses the training of an existing model. - rpc PauseModel(PauseModelRequest) returns (Model) { - option (google.api.http) = { - post: "/v2alpha/{name=projects/*/locations/*/catalogs/*/models/*}:pause" - body: "*" - }; - option (google.api.method_signature) = "name"; - } - - // Resumes the training of an existing model. - rpc ResumeModel(ResumeModelRequest) returns (Model) { - option (google.api.http) = { - post: "/v2alpha/{name=projects/*/locations/*/catalogs/*/models/*}:resume" - body: "*" - }; - option (google.api.method_signature) = "name"; - } - - // Deletes an existing model. - rpc DeleteModel(DeleteModelRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v2alpha/{name=projects/*/locations/*/catalogs/*/models/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists all the models linked to this event store. - rpc ListModels(ListModelsRequest) returns (ListModelsResponse) { - option (google.api.http) = { - get: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/models" - }; - option (google.api.method_signature) = "parent"; - } - - // Update of model metadata. Only fields that - // currently can be updated are: `filtering_option` and - // `periodic_tuning_state`. - // If other values are provided, this API method ignores them. - rpc UpdateModel(UpdateModelRequest) returns (Model) { - option (google.api.http) = { - patch: "/v2alpha/{model.name=projects/*/locations/*/catalogs/*/models/*}" - body: "model" - }; - option (google.api.method_signature) = "model,update_mask"; - } - - // Tunes an existing model. - rpc TuneModel(TuneModelRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2alpha/{name=projects/*/locations/*/catalogs/*/models/*}:tune" - body: "*" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2alpha.TuneModelResponse" - metadata_type: "google.cloud.retail.v2alpha.TuneModelMetadata" - }; - } -} - -// Request for creating a model. -message CreateModelRequest { - // Required. The parent resource under which to create the model. 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 payload of the [Model][google.cloud.retail.v2alpha.Model] to - // create. - Model model = 2 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Whether to run a dry run to validate the request (without - // actually creating the model). - bool dry_run = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// Request for updating an existing model. -message UpdateModelRequest { - // Required. The body of the updated - // [Model][google.cloud.retail.v2alpha.Model]. - Model model = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Indicates which fields in the provided 'model' to - // update. If not set, by default updates all fields. - google.protobuf.FieldMask update_mask = 2 - [(google.api.field_behavior) = OPTIONAL]; -} - -// Request for getting a model. -message GetModelRequest { - // Required. The resource name of the - // [Model][google.cloud.retail.v2alpha.Model] to get. Format: - // `projects/{project_number}/locations/{location_id}/catalogs/{catalog}/models/{model_id}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Model" } - ]; -} - -// Request for pausing training of a model. -message PauseModelRequest { - // Required. The name of the model to pause. - // Format: - // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Model" } - ]; -} - -// Request for resuming training of a model. -message ResumeModelRequest { - // Required. The name of the model to resume. - // Format: - // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for listing models associated with a resource. -message ListModelsRequest { - // Required. The parent for which to list models. - // 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 `ListModels` - // call. Provide this to retrieve the subsequent page. - string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// Request for deleting a model. -message DeleteModelRequest { - // Required. The resource name of the - // [Model][google.cloud.retail.v2alpha.Model] to delete. Format: - // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Model" } - ]; -} - -// Response to a ListModelRequest. -message ListModelsResponse { - // List of Models. - repeated Model models = 1; - - // Pagination token, if not returned indicates the last page. - string next_page_token = 2; -} - -// Request to manually start a tuning process now (instead of waiting for -// the periodically scheduled tuning to happen). -message TuneModelRequest { - // Required. The resource name of the model to tune. - // Format: - // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Model" } - ]; -} - -// Metadata associated with a create operation. -message CreateModelMetadata { - // The resource name of the model that this create applies to. - // Format: - // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` - string model = 1; -} - -// Metadata associated with a tune operation. -message TuneModelMetadata { - // The resource name of the model that this tune applies to. - // Format: - // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` - string model = 1; -} - -// Response associated with a tune operation. -message TuneModelResponse {} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/prediction_service.proto b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/prediction_service.proto deleted file mode 100644 index 30fb4bf464d..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/prediction_service.proto +++ /dev/null @@ -1,226 +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/user_event.proto"; -import "google/protobuf/struct.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Alpha"; -option go_package = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; -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: "*" - additional_bindings { - post: "/v2alpha/{placement=projects/*/locations/*/catalogs/*/servingConfigs/*}:predict" - body: "*" - } - }; - } -} - -// Request message for Predict method. -message PredictRequest { - // Required. Full resource name of the format: - // `{placement=projects/*/locations/global/catalogs/default_catalog/servingConfigs/*}` - // or - // `{placement=projects/*/locations/global/catalogs/default_catalog/placements/*}`. - // We recommend using the `servingConfigs` resource. `placements` is a legacy - // resource. - // The ID of the Recommendations AI serving config or placement. - // Before you can request predictions from your model, you must create at - // least one serving config or placement for it. For more information, see - // [Manage serving configs] - // (https://cloud.google.com/retail/docs/manage-configs). - // - // The full list of available serving configs can be seen at - // https://console.cloud.google.com/ai/retail/catalogs/default_catalog/configs - 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.v2alpha.UserEvent.visitor_id] or - // [UserInfo.user_id][google.cloud.retail.v2alpha.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.v2alpha.UserEvent.visitor_id] to - // a random unique ID and leave - // [UserInfo.user_id][google.cloud.retail.v2alpha.UserInfo.user_id] unset. - UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED]; - - // Maximum number of results to return. 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; - - // This field is not used; leave it unset. - string page_token = 4 [deprecated = true]; - - // 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 *no* - // results. If instead you want empty result sets to return generic - // (unfiltered) popular products, set `strictFiltering` to False in - // `PredictRequest.params`. Note that the API will never return items with - // storageStatus of "EXPIRED" or "DELETED" regardless of filter choices. - // - // If `filterSyntaxV2` is set to true under the `params` field, then - // attribute-based expressions are expected instead of the above described - // tag-based syntax. Examples: - // - // * (colors: ANY("Red", "Blue")) AND NOT (categories: ANY("Phones")) - // * (availability: ANY("IN_STOCK")) AND - // (colors: ANY("Red") OR categories: ANY("Phones")) - // - // For more information, see - // [Filter recommendations](https://cloud.google.com/retail/docs/filter-recs). - 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 a 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. - // * `filterSyntaxV2`: Boolean. False by default. If set to true, the `filter` - // field is interpreteted according to the new, attribute-based syntax. - 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.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/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/product.proto b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/product.proto deleted file mode 100644 index 3dc548fde24..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/product.proto +++ /dev/null @@ -1,598 +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 = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; -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]. - // Note that this is only applicable to - // [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] and - // [Type.COLLECTION][google.cloud.retail.v2alpha.Product.Type.COLLECTION], - // and ignored for - // [Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT]. In - // general, we suggest the users to delete the stale products explicitly, - // instead of using this field to determine staleness. - // - // 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. Note that this is only - // applicable to - // [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] and - // [Type.COLLECTION][google.cloud.retail.v2alpha.Product.Type.COLLECTION], - // and ignored for - // [Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT]. In - // general, we suggest the users to delete the stale products explicitly, - // instead of using this field to determine staleness. - // - // 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 - // an 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, 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]. - // Note that this is only applicable to - // [Type.PRIMARY][google.cloud.retail.v2alpha.Product.Type.PRIMARY] and - // [Type.COLLECTION][google.cloud.retail.v2alpha.Product.Type.COLLECTION], and - // ignored for - // [Type.VARIANT][google.cloud.retail.v2alpha.Product.Type.VARIANT]. - 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] - // - // The maximum number of paths is 30. Otherwise, an INVALID_ARGUMENT error is - // returned. - // - // Note: Returning more fields in - // [SearchResponse][google.cloud.retail.v2alpha.SearchResponse] can increase - // response payload size and serving latency. - // - // This field is deprecated. Use the retrievable site-wide control instead. - google.protobuf.FieldMask retrievable_fields = 30 [deprecated = true]; - - // 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]; - - // Output only. A list of local inventories specific to different places. - // - // This field can be managed by - // [ProductService.AddLocalInventories][google.cloud.retail.v2alpha.ProductService.AddLocalInventories] - // and - // [ProductService.RemoveLocalInventories][google.cloud.retail.v2alpha.ProductService.RemoveLocalInventories] - // APIs if fine-grained, high-volume updates are necessary. - repeated LocalInventory local_inventories = 35 - [(google.api.field_behavior) = OUTPUT_ONLY]; -} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/product_service.proto b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/product_service.proto deleted file mode 100644 index c954d8c6114..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/product_service.proto +++ /dev/null @@ -1,988 +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 = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; -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 - // [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] - // or - // [ProductService.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. - // 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 is 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 - // [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] - // or - // [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. - // - // When inventory is updated with - // [ProductService.CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] - // and - // [ProductService.UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct], - // the specified inventory field value(s) overwrite any existing value(s) - // while ignoring the last update time for this field. Furthermore, the last - // update times for the specified inventory fields are overwritten by the - // times of the - // [ProductService.CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] - // or - // [ProductService.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 is used. - // - // If no inventory fields are set in - // [SetInventoryRequest.set_mask][google.cloud.retail.v2alpha.SetInventoryRequest.set_mask], - // then any existing inventory information is preserved. - // - // Pre-existing inventory information can only be updated with - // [ProductService.SetInventory][google.cloud.retail.v2alpha.ProductService.SetInventory], - // [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlaces], - // and - // [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces]. - // - // The returned [Operation][google.longrunning.Operation]s is obsolete after - // one day, and the [GetOperation][google.longrunning.Operations.GetOperation] - // API returns `NOT_FOUND` afterwards. - // - // If conflicting updates are issued, the - // [Operation][google.longrunning.Operation]s associated with the stale - // updates are not marked as [done][google.longrunning.Operation.done] until - // they are obsolete. - 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" - }; - } - - // It is recommended to use the - // [ProductService.AddLocalInventories][google.cloud.retail.v2alpha.ProductService.AddLocalInventories] - // method instead of - // [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlaces]. - // [ProductService.AddLocalInventories][google.cloud.retail.v2alpha.ProductService.AddLocalInventories] - // achieves the same results but provides more fine-grained control over - // ingesting local inventory data. - // - // 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 - // [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] - // or - // [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. - // - // The returned [Operation][google.longrunning.Operation]s will be obsolete - // after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] - // API will return NOT_FOUND afterwards. - // - // If conflicting updates are issued, the - // [Operation][google.longrunning.Operation]s associated with the stale - // updates will not be marked as [done][google.longrunning.Operation.done] - // until being obsolete. - 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" - }; - } - - // It is recommended to use the - // [ProductService.RemoveLocalInventories][google.cloud.retail.v2alpha.ProductService.RemoveLocalInventories] - // method instead of - // [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces]. - // [ProductService.RemoveLocalInventories][google.cloud.retail.v2alpha.ProductService.RemoveLocalInventories] - // achieves the same results but provides more fine-grained control over - // ingesting local inventory data. - // - // 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 - // [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] - // or - // [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. - // - // The returned [Operation][google.longrunning.Operation]s will be obsolete - // after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] - // API will return NOT_FOUND afterwards. - // - // If conflicting updates are issued, the - // [Operation][google.longrunning.Operation]s associated with the stale - // updates will not be marked as [done][google.longrunning.Operation.done] - // until being obsolete. - 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 - // [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] - // or - // [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. - // - // Local inventory information can only be modified using this method. - // [ProductService.CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] - // and - // [ProductService.UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct] - // has no effect on local inventories. - // - // The returned [Operation][google.longrunning.Operation]s will be obsolete - // after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] - // API will return NOT_FOUND afterwards. - // - // If conflicting updates are issued, the - // [Operation][google.longrunning.Operation]s associated with the stale - // updates will not be marked as [done][google.longrunning.Operation.done] - // until being obsolete. - 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 - // [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] - // or - // [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. - // - // Local inventory information can only be removed using this method. - // [ProductService.CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] - // and - // [ProductService.UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct] - // has no effect on local inventories. - // - // The returned [Operation][google.longrunning.Operation]s will be obsolete - // after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] - // API will return NOT_FOUND afterwards. - // - // If conflicting updates are issued, the - // [Operation][google.longrunning.Operation]s associated with the stale - // updates will not be marked as [done][google.longrunning.Operation.done] - // until being obsolete. - 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 -// [ProductService.CreateProduct][google.cloud.retail.v2alpha.ProductService.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 -// [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.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 -// [ProductService.UpdateProduct][google.cloud.retail.v2alpha.ProductService.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. - // - // 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.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 -// [ProductService.DeleteProduct][google.cloud.retail.v2alpha.ProductService.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" } - ]; - - // This value only applies to the case when the target product is of type - // PRIMARY. - // When deleting a product of VARIANT/COLLECTION type, this value - // will be ignored. - // When set to true, the subsequent variant products will be - // deleted. - // When set to false, if the primary product has active variant products, an - // error will be returned. - bool force = 4; -} - -// 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 -// [ProductService.SetInventory][google.cloud.retail.v2alpha.ProductService.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][google.cloud.retail.v2alpha.Product.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][google.cloud.retail.v2alpha.Product.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][google.cloud.retail.v2alpha.Product.fulfillment_info] - // * Checks that only the desired fulfillment info types have empty - // [SetInventoryRequest.inventory.fulfillment_info.place_ids][google.cloud.retail.v2alpha.FulfillmentInfo.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, - // [ProductService.UpdateProduct][google.cloud.retail.v2alpha.ProductService.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 -// [ProductService.SetInventory][google.cloud.retail.v2alpha.ProductService.SetInventory] -// method. -message SetInventoryMetadata {} - -// Response of the SetInventoryRequest. Currently empty because -// there is no meaningful response populated from the -// [ProductService.SetInventory][google.cloud.retail.v2alpha.ProductService.SetInventory] -// method. -message SetInventoryResponse {} - -// Request message for -// [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.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][google.cloud.retail.v2alpha.FulfillmentInfo.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 -// [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2alpha.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.v2alpha.ProductService.AddFulfillmentPlaces] -// method. -message AddFulfillmentPlacesResponse {} - -// Request message for -// [ProductService.AddLocalInventories][google.cloud.retail.v2alpha.ProductService.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 -// [ProductService.AddLocalInventories][google.cloud.retail.v2alpha.ProductService.AddLocalInventories] -// method. -message AddLocalInventoriesMetadata {} - -// Response of the -// [ProductService.AddLocalInventories][google.cloud.retail.v2alpha.ProductService.AddLocalInventories] -// API. Currently empty because there is no meaningful response populated from -// the -// [ProductService.AddLocalInventories][google.cloud.retail.v2alpha.ProductService.AddLocalInventories] -// method. -message AddLocalInventoriesResponse {} - -// Request message for -// [ProductService.RemoveLocalInventories][google.cloud.retail.v2alpha.ProductService.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 -// [ProductService.RemoveLocalInventories][google.cloud.retail.v2alpha.ProductService.RemoveLocalInventories] -// method. -message RemoveLocalInventoriesMetadata {} - -// Response of the -// [ProductService.RemoveLocalInventories][google.cloud.retail.v2alpha.ProductService.RemoveLocalInventories] -// API. Currently empty because there is no meaningful response populated from -// the -// [ProductService.RemoveLocalInventories][google.cloud.retail.v2alpha.ProductService.RemoveLocalInventories] -// method. -message RemoveLocalInventoriesResponse {} - -// Request message for -// [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.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][google.cloud.retail.v2alpha.FulfillmentInfo.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 -// [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces] -// method. -message RemoveFulfillmentPlacesMetadata {} - -// Response of the RemoveFulfillmentPlacesRequest. Currently empty because there -// is no meaningful response populated from the -// [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces] -// method. -message RemoveFulfillmentPlacesResponse {} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/promotion.proto b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/promotion.proto deleted file mode 100644 index 63a80737cc7..00000000000 --- a/owl-bot-staging/google-cloud-retail/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 = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; -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/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/purge_config.proto b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/purge_config.proto deleted file mode 100644 index b7b9ab81441..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/purge_config.proto +++ /dev/null @@ -1,174 +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 = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; -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, - (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.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/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/search_service.proto b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/search_service.proto deleted file mode 100644 index f2931e40ed6..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/search_service.proto +++ /dev/null @@ -1,1032 +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 = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; -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"; -option (google.api.resource_definition) = { - type: "retail.googleapis.com/Experiment" - pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/experiments/{experiment}" -}; - -// Service for search. -// -// This feature is only available for users who have Retail Search enabled. -// 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. - // 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: "*" - additional_bindings { - post: "/v2alpha/{placement=projects/*/locations/*/catalogs/*/servingConfigs/*}: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 40. - // - // For all numerical facet keys that appear in the list of products from - // the catalog, the percentiles 0, 10, 30, 50, 70, 90 and 100 are - // computed from their distribution weekly. If the model assigns a high - // score to a numerical facet key and its intervals are not specified in - // the search request, these percentiles will become the bounds - // for its intervals and will be returned in the response. If the - // facet key intervals are specified in the request, then the specified - // intervals will be returned instead. - 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; - - // True to make facet keys case insensitive when getting faceting - // values with prefixes or contains; false otherwise. - bool case_insensitive = 10; - - // The order in which - // [SearchResponse.Facet.values][google.cloud.retail.v2alpha.SearchResponse.Facet.values] - // are returned. - // - // Allowed values are: - // - // * "count desc", which means order by - // [SearchResponse.Facet.values.count][google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue.count] - // descending. - // - // * "value desc", which means order by - // [SearchResponse.Facet.values.value][google.cloud.retail.v2alpha.SearchResponse.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, - // [SearchResponse.Facet.values.value][google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue.value] - // will be always "1" and - // [SearchResponse.Facet.values.count][google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue.count] - // will be the number of results that match 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; - - // Returns the min and max value for each numerical facet intervals. - // Ignored for textual facets. - bool return_min_max = 11; - } - - // 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 50. 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. - // - // 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.v2alpha.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.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 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.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. In this case, server behavior - // 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. In this case, server behavior defaults to - // [Mode.AUTO][google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec.Mode.AUTO]. - MODE_UNSPECIFIED = 0; - - // Let CRS decide whether to use personalization based on quality of user - // event data. - AUTO = 1; - - // Disable personalization. - DISABLED = 2; - } - - // Defaults to - // [Mode.AUTO][google.cloud.retail.v2alpha.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. In this case, server behavior - // defaults to - // [Mode.AUTO][google.cloud.retail.v2alpha.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.v2alpha.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.v2alpha.SearchRequest.SpellCorrectionSpec.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. In this case, server behavior 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][google.cloud.retail.v2alpha.SearchResponse.SearchResult] - // and - // [SearchResponse.Facet][google.cloud.retail.v2alpha.SearchResponse.Facet] - // will be returned. - SEARCH_MODE_UNSPECIFIED = 0; - - // Only product search will be performed. The faceted search will be - // disabled. - // - // Only - // [SearchResponse.SearchResult][google.cloud.retail.v2alpha.SearchResponse.SearchResult] - // will be returned. - // [SearchResponse.Facet][google.cloud.retail.v2alpha.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_specs][google.cloud.retail.v2alpha.SearchRequest.facet_specs] - // 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][google.cloud.retail.v2alpha.SearchResponse.Facet] - // will be returned. - // [SearchResponse.SearchResult][google.cloud.retail.v2alpha.SearchResponse.SearchResult] - // will not be returned. - FACETED_SEARCH_ONLY = 2; - } - - // Required. The resource name of the Retail Search serving config, such as - // `projects/*/locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` - // or the name of the legacy placement resource, such as - // `projects/*/locations/global/catalogs/default_catalog/placements/default_search`. - // This field is used to identify the serving config 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.v2alpha.SearchRequest.filter] and - // [page_categories][google.cloud.retail.v2alpha.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.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 200 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][google.cloud.retail.v2alpha.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.local_inventories.attributes][google.cloud.retail.v2alpha.LocalInventory.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. Must be set 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, 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. - // - // Notice that if both - // [ServingConfig.personalization_spec][google.cloud.retail.v2alpha.ServingConfig.personalization_spec] - // and - // [SearchRequest.personalization_spec][google.cloud.retail.v2alpha.SearchRequest.personalization_spec] - // are set. - // [SearchRequest.personalization_spec][google.cloud.retail.v2alpha.SearchRequest.personalization_spec] - // will override - // [ServingConfig.personalization_spec][google.cloud.retail.v2alpha.ServingConfig.personalization_spec]. - 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; - - // The entity for customers that may run multiple different entities, domains, - // sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, - // `google.com`, `youtube.com`, etc. - // If this is set, it should be exactly matched with - // [UserEvent.entity][google.cloud.retail.v2alpha.UserEvent.entity] to get - // search results boosted by entity. - string entity = 38; -} - -// 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; - - // Specifies previous events related to this product for this user based on - // [UserEvent][google.cloud.retail.v2alpha.UserEvent] with same - // [SearchRequest.visitor_id][google.cloud.retail.v2alpha.SearchRequest.visitor_id] - // or [UserInfo.user_id][google.cloud.retail.v2alpha.UserInfo.user_id]. - // - // This is set only when - // [SearchRequest.PersonalizationSpec.mode][google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec.mode] - // is - // [SearchRequest.PersonalizationSpec.Mode.AUTO][google.cloud.retail.v2alpha.SearchRequest.PersonalizationSpec.Mode.AUTO]. - // - // Possible values: - // - // * `purchased`: Indicates that this product has been purchased before. - repeated string personal_labels = 7; - } - - // 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 minimum value in the - // [FacetValue.interval][google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue.interval]. - // Only supported on numerical facets and returned if - // [SearchRequest.FacetSpec.FacetKey.return_min_max][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.return_min_max] - // is true. - double min_value = 5; - - // The maximum value in the - // [FacetValue.interval][google.cloud.retail.v2alpha.SearchResponse.Facet.FacetValue.interval]. - // Only supported on numerical facets and returned if - // [SearchRequest.FacetSpec.FacetKey.return_min_max][google.cloud.retail.v2alpha.SearchRequest.FacetSpec.FacetKey.return_min_max] - // is true. - double max_value = 6; - } - - // 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; - - // 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 is used for search. - 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 is performed, and only - // [redirect_uri][google.cloud.retail.v2alpha.SearchResponse.redirect_uri] and - // [attribution_token][google.cloud.retail.v2alpha.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.v2alpha.SearchRequest.BoostSpec.condition_boost_specs] - // that are not applied during serving. - repeated SearchRequest.BoostSpec.ConditionBoostSpec - invalid_condition_boost_specs = 14; - - // Metadata related to A/B testing - // [Experiment][google.cloud.retail.v2alpha.Experiment] associated with this - // response. Only exists when an experiment is triggered. - repeated ExperimentInfo experiment_info = 17; -} - -// Metadata for active A/B testing [Experiments][]. -message ExperimentInfo { - // Metadata for active serving config A/B tests. - message ServingConfigExperiment { - // The fully qualified resource name of the original - // [SearchRequest.placement][google.cloud.retail.v2alpha.SearchRequest.placement] - // in the search request prior to reassignment by experiment API. For - // example: `projects/*/locations/*/catalogs/*/servingConfigs/*`. - string original_serving_config = 1 [(google.api.resource_reference) = { - type: "retail.googleapis.com/ServingConfig" - }]; - - // The fully qualified resource name of the serving config - // [VariantArm.serving_config_id][] responsible for generating the search - // response. For example: - // `projects/*/locations/*/catalogs/*/servingConfigs/*`. - string experiment_serving_config = 2 [(google.api.resource_reference) = { - type: "retail.googleapis.com/ServingConfig" - }]; - } - - // Information associated with the specific experiment entity being recorded. - oneof experiment_metadata { - // A/B test between existing Cloud Retail Search - // [ServingConfig][google.cloud.retail.v2alpha.ServingConfig]s. - ServingConfigExperiment serving_config_experiment = 2; - } - - // The fully qualified resource name of the experiment that provides the - // serving config under test, should an active experiment exist. For example: - // `projects/*/locations/global/catalogs/default_catalog/experiments/experiment_id` - string experiment = 1 [(google.api.resource_reference) = { - type: "retail.googleapis.com/Experiment" - }]; -} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/serving_config.proto b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/serving_config.proto deleted file mode 100644 index d4c89cb0c17..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/serving_config.proto +++ /dev/null @@ -1,281 +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 = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; -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). -message ServingConfig { - option (google.api.resource) = { - type: "retail.googleapis.com/ServingConfig" - pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}" - }; - - // What type of diversity - data or rule based. - enum DiversityType { - // Default value. - DIVERSITY_TYPE_UNSPECIFIED = 0; - - // Rule based diversity. - RULE_BASED_DIVERSITY = 2; - - // Data driven diversity. - DATA_DRIVEN_DIVERSITY = 3; - } - - // 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 in the same - // [Catalog][google.cloud.retail.v2alpha.Catalog] 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-reranking` - // * `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][google.cloud.retail.v2alpha.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; - - // What kind of diversity to use - data driven or rule based. If unset, the - // server behavior defaults to - // [RULE_BASED_DIVERSITY][google.cloud.retail.v2alpha.ServingConfig.DiversityType.RULE_BASED_DIVERSITY]. - DiversityType diversity_type = 20; - - // 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; - - // The specification for personalization spec. - // - // 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]. - // - // Notice that if both - // [ServingConfig.personalization_spec][google.cloud.retail.v2alpha.ServingConfig.personalization_spec] - // and - // [SearchRequest.personalization_spec][google.cloud.retail.v2alpha.SearchRequest.personalization_spec] - // are set. - // [SearchRequest.personalization_spec][google.cloud.retail.v2alpha.SearchRequest.personalization_spec] - // will override - // [ServingConfig.personalization_spec][google.cloud.retail.v2alpha.ServingConfig.personalization_spec]. - SearchRequest.PersonalizationSpec personalization_spec = 21; - - // 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/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/serving_config_service.proto b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/serving_config_service.proto deleted file mode 100644 index abe94af65af..00000000000 --- a/owl-bot-staging/google-cloud-retail/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 = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; -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/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/user_event.proto b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/user_event.proto deleted file mode 100644 index 8ace03d047d..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/user_event.proto +++ /dev/null @@ -1,354 +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 = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; -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. - // - // 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.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 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.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, 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; - - // The entity for customers that may run multiple different entities, domains, - // sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, - // `google.com`, `youtube.com`, etc. - // It is recommended to set this field to get better per-entity search, - // completion and prediction results. - string entity = 23; -} - -// 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/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/user_event_service.proto b/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/user_event_service.proto deleted file mode 100644 index 2a825e65230..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/protos/google/cloud/retail/v2alpha/user_event_service.proto +++ /dev/null @@ -1,210 +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 = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb"; -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 - // are not annotated with detailed product information for products that are - // missing from the catalog when the user event is ingested. These - // events are stored as unjoined events with limited usage on training and - // serving. You can use this method to start a join operation on specified - // events with the latest version of product catalog. You can also use this - // method 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]; - - // If set to true, the user event will be written asynchronously after - // validation, and the API will respond without waiting for the write. - // Therefore, silent failures can occur even if the API returns success. In - // case of silent failures, error messages can be found in Stackdriver logs. - bool write_async = 3; -} - -// Request message for CollectUserEvent method. -message CollectUserEventRequest { - // The rule that can convert the raw_json to a user event. It is needed - // only when the raw_json is set. - oneof conversion_rule { - // The prebuilt rule name that can convert a specific type of raw_json. - // For example: "ga4_bq" rule for the GA4 user event schema. - string prebuilt_rule = 6; - } - - // 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; - - // An arbitrary serialized JSON string that contains necessary information - // that can comprise a user event. When this field is specified, the - // user_event field will be ignored. Note: line-delimited JSON is not - // supported, a single JSON only. - string raw_json = 5; -} - -// 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.add_catalog_attribute.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.add_catalog_attribute.js deleted file mode 100644 index cd1f26ba0a0..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.add_catalog_attribute.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.batch_remove_catalog_attributes.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.batch_remove_catalog_attributes.js deleted file mode 100644 index 909b1f16079..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.batch_remove_catalog_attributes.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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, attributeKeys) { - // [START retail_v2alpha_generated_CatalogService_BatchRemoveCatalogAttributes_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The attributes config resource shared by all catalog attributes - * being deleted. Format: - * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` - */ - // const attributesConfig = 'abc123' - /** - * Required. The attribute name keys of the - * CatalogAttribute google.cloud.retail.v2alpha.CatalogAttribute s to - * delete. A maximum of 1000 catalog attributes can be deleted in a batch. - */ - // const attributeKeys = 'abc123' - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callBatchRemoveCatalogAttributes() { - // Construct request - const request = { - attributesConfig, - attributeKeys, - }; - - // Run request - const response = await retailClient.batchRemoveCatalogAttributes(request); - console.log(response); - } - - callBatchRemoveCatalogAttributes(); - // [END retail_v2alpha_generated_CatalogService_BatchRemoveCatalogAttributes_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.get_attributes_config.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.get_attributes_config.js deleted file mode 100644 index aac5dac8ddb..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.get_attributes_config.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.get_completion_config.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.get_completion_config.js deleted file mode 100644 index e875759bbea..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.get_completion_config.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.get_default_branch.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.get_default_branch.js deleted file mode 100644 index 4c14d06856f..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.get_default_branch.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.list_catalogs.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.list_catalogs.js deleted file mode 100644 index e8b3d5f2d83..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.list_catalogs.js +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.remove_catalog_attribute.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.remove_catalog_attribute.js deleted file mode 100644 index faed21407fd..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.remove_catalog_attribute.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.replace_catalog_attribute.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.replace_catalog_attribute.js deleted file mode 100644 index ca486f3d716..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.replace_catalog_attribute.js +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.set_default_branch.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.set_default_branch.js deleted file mode 100644 index 8be4d79d371..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.set_default_branch.js +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.update_attributes_config.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.update_attributes_config.js deleted file mode 100644 index 13c58537108..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.update_attributes_config.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.update_catalog.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.update_catalog.js deleted file mode 100644 index 29e30046130..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.update_catalog.js +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.update_completion_config.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.update_completion_config.js deleted file mode 100644 index def26a2dbf0..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/catalog_service.update_completion_config.js +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/completion_service.complete_query.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/completion_service.complete_query.js deleted file mode 100644 index 9dbf368c009..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/completion_service.complete_query.js +++ /dev/null @@ -1,137 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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' - /** - * Note that this field applies for `user-data` dataset only. For requests - * with `cloud-retail` dataset, setting this field has no effect. - * 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. We recommend that you - * leave this field empty. - * It can 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 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 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 - /** - * If true, attribute suggestions are enabled and provided in response. - * This field is only available for "cloud-retail" dataset. - */ - // const enableAttributeSuggestions = true - /** - * The entity for customers that may run multiple different entities, domains, - * sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, - * `google.com`, `youtube.com`, etc. - * If this is set, it should be exactly matched with - * UserEvent.entity google.cloud.retail.v2alpha.UserEvent.entity to get - * per-entity autocomplete results. - */ - // const entity = 'abc123' - - // 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/completion_service.import_completion_data.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/completion_service.import_completion_data.js deleted file mode 100644 index 7ebf210565d..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/completion_service.import_completion_data.js +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 is sent to - * specified Pub/Sub topic. The message data is 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/control_service.create_control.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/control_service.create_control.js deleted file mode 100644 index 5d9cc8c6f3c..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/control_service.create_control.js +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/control_service.delete_control.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/control_service.delete_control.js deleted file mode 100644 index 192850511a2..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/control_service.delete_control.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/control_service.get_control.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/control_service.get_control.js deleted file mode 100644 index 9e07fb8ced4..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/control_service.get_control.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the Control to get. 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/control_service.list_controls.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/control_service.list_controls.js deleted file mode 100644 index 778d71bcd40..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/control_service.list_controls.js +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/control_service.update_control.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/control_service.update_control.js deleted file mode 100644 index ddae99da36f..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/control_service.update_control.js +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/merchant_center_account_link_service.create_merchant_center_account_link.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/merchant_center_account_link_service.create_merchant_center_account_link.js deleted file mode 100644 index fb1ea60a850..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/merchant_center_account_link_service.create_merchant_center_account_link.js +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, merchantCenterAccountLink) { - // [START retail_v2alpha_generated_MerchantCenterAccountLinkService_CreateMerchantCenterAccountLink_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The branch resource where this MerchantCenterAccountLink will be - * created. Format: - * projects/{PROJECT_NUMBER}/locations/global/catalogs/{CATALOG_ID}} - */ - // const parent = 'abc123' - /** - * Required. The - * MerchantCenterAccountLink google.cloud.retail.v2alpha.MerchantCenterAccountLink - * to create. - * If the caller does not have permission to create the - * MerchantCenterAccountLink google.cloud.retail.v2alpha.MerchantCenterAccountLink, - * regardless of whether or not it exists, a PERMISSION_DENIED error is - * returned. - */ - // const merchantCenterAccountLink = {} - - // Imports the Retail library - const {MerchantCenterAccountLinkServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new MerchantCenterAccountLinkServiceClient(); - - async function callCreateMerchantCenterAccountLink() { - // Construct request - const request = { - parent, - merchantCenterAccountLink, - }; - - // Run request - const [operation] = await retailClient.createMerchantCenterAccountLink(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateMerchantCenterAccountLink(); - // [END retail_v2alpha_generated_MerchantCenterAccountLinkService_CreateMerchantCenterAccountLink_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/merchant_center_account_link_service.delete_merchant_center_account_link.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/merchant_center_account_link_service.delete_merchant_center_account_link.js deleted file mode 100644 index 941b02e5328..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/merchant_center_account_link_service.delete_merchant_center_account_link.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by 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_MerchantCenterAccountLinkService_DeleteMerchantCenterAccountLink_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/merchantCenterAccountLinks/{merchant_center_account_link_id} - */ - // const name = 'abc123' - - // Imports the Retail library - const {MerchantCenterAccountLinkServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new MerchantCenterAccountLinkServiceClient(); - - async function callDeleteMerchantCenterAccountLink() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.deleteMerchantCenterAccountLink(request); - console.log(response); - } - - callDeleteMerchantCenterAccountLink(); - // [END retail_v2alpha_generated_MerchantCenterAccountLinkService_DeleteMerchantCenterAccountLink_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/merchant_center_account_link_service.list_merchant_center_account_links.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/merchant_center_account_link_service.list_merchant_center_account_links.js deleted file mode 100644 index 55634ba9ff8..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/merchant_center_account_link_service.list_merchant_center_account_links.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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_MerchantCenterAccountLinkService_ListMerchantCenterAccountLinks_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent Catalog of the resource. - * It must match this format: - * projects/{PROJECT_NUMBER}/locations/global/catalogs/{CATALOG_ID} - */ - // const parent = 'abc123' - - // Imports the Retail library - const {MerchantCenterAccountLinkServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new MerchantCenterAccountLinkServiceClient(); - - async function callListMerchantCenterAccountLinks() { - // Construct request - const request = { - parent, - }; - - // Run request - const response = await retailClient.listMerchantCenterAccountLinks(request); - console.log(response); - } - - callListMerchantCenterAccountLinks(); - // [END retail_v2alpha_generated_MerchantCenterAccountLinkService_ListMerchantCenterAccountLinks_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.create_model.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.create_model.js deleted file mode 100644 index 1e705fb6fca..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.create_model.js +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, model) { - // [START retail_v2alpha_generated_ModelService_CreateModel_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent resource under which to create the model. Format: - * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` - */ - // const parent = 'abc123' - /** - * Required. The payload of the Model google.cloud.retail.v2alpha.Model to - * create. - */ - // const model = {} - /** - * Optional. Whether to run a dry run to validate the request (without - * actually creating the model). - */ - // const dryRun = true - - // Imports the Retail library - const {ModelServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ModelServiceClient(); - - async function callCreateModel() { - // Construct request - const request = { - parent, - model, - }; - - // Run request - const [operation] = await retailClient.createModel(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateModel(); - // [END retail_v2alpha_generated_ModelService_CreateModel_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.delete_model.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.delete_model.js deleted file mode 100644 index 9e0fa545ecb..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.delete_model.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by 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_ModelService_DeleteModel_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the - * Model google.cloud.retail.v2alpha.Model to delete. Format: - * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` - */ - // const name = 'abc123' - - // Imports the Retail library - const {ModelServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ModelServiceClient(); - - async function callDeleteModel() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.deleteModel(request); - console.log(response); - } - - callDeleteModel(); - // [END retail_v2alpha_generated_ModelService_DeleteModel_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.get_model.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.get_model.js deleted file mode 100644 index 082a17dc5fd..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.get_model.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by 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_ModelService_GetModel_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the - * Model google.cloud.retail.v2alpha.Model to get. Format: - * `projects/{project_number}/locations/{location_id}/catalogs/{catalog}/models/{model_id}` - */ - // const name = 'abc123' - - // Imports the Retail library - const {ModelServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ModelServiceClient(); - - async function callGetModel() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.getModel(request); - console.log(response); - } - - callGetModel(); - // [END retail_v2alpha_generated_ModelService_GetModel_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.list_models.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.list_models.js deleted file mode 100644 index 2985c1214f3..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.list_models.js +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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_ModelService_ListModels_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent for which to list models. - * 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 `ListModels` - * call. Provide this to retrieve the subsequent page. - */ - // const pageToken = 'abc123' - - // Imports the Retail library - const {ModelServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ModelServiceClient(); - - async function callListModels() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await retailClient.listModelsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListModels(); - // [END retail_v2alpha_generated_ModelService_ListModels_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.pause_model.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.pause_model.js deleted file mode 100644 index d8d1fc88cfb..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.pause_model.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by 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_ModelService_PauseModel_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the model to pause. - * Format: - * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` - */ - // const name = 'abc123' - - // Imports the Retail library - const {ModelServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ModelServiceClient(); - - async function callPauseModel() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.pauseModel(request); - console.log(response); - } - - callPauseModel(); - // [END retail_v2alpha_generated_ModelService_PauseModel_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.resume_model.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.resume_model.js deleted file mode 100644 index 03238aa786a..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.resume_model.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by 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_ModelService_ResumeModel_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the model to resume. - * Format: - * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` - */ - // const name = 'abc123' - - // Imports the Retail library - const {ModelServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ModelServiceClient(); - - async function callResumeModel() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.resumeModel(request); - console.log(response); - } - - callResumeModel(); - // [END retail_v2alpha_generated_ModelService_ResumeModel_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.tune_model.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.tune_model.js deleted file mode 100644 index 3a42c227e07..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.tune_model.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by 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_ModelService_TuneModel_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the model to tune. - * Format: - * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` - */ - // const name = 'abc123' - - // Imports the Retail library - const {ModelServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ModelServiceClient(); - - async function callTuneModel() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await retailClient.tuneModel(request); - const [response] = await operation.promise(); - console.log(response); - } - - callTuneModel(); - // [END retail_v2alpha_generated_ModelService_TuneModel_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.update_model.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.update_model.js deleted file mode 100644 index d9464299239..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/model_service.update_model.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(model) { - // [START retail_v2alpha_generated_ModelService_UpdateModel_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The body of the updated - * Model google.cloud.retail.v2alpha.Model. - */ - // const model = {} - /** - * Optional. Indicates which fields in the provided 'model' to - * update. If not set, by default updates all fields. - */ - // const updateMask = {} - - // Imports the Retail library - const {ModelServiceClient} = require('@google-cloud/retail').v2alpha; - - // Instantiates a client - const retailClient = new ModelServiceClient(); - - async function callUpdateModel() { - // Construct request - const request = { - model, - }; - - // Run request - const response = await retailClient.updateModel(request); - console.log(response); - } - - callUpdateModel(); - // [END retail_v2alpha_generated_ModelService_UpdateModel_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/prediction_service.predict.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/prediction_service.predict.js deleted file mode 100644 index 5b950b62942..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/prediction_service.predict.js +++ /dev/null @@ -1,187 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of the format: - * `{placement=projects/* /locations/global/catalogs/default_catalog/servingConfigs/*}` - * or - * `{placement=projects/* /locations/global/catalogs/default_catalog/placements/*}`. - * We recommend using the `servingConfigs` resource. `placements` is a legacy - * resource. - * The ID of the Recommendations AI serving config or placement. - * Before you can request predictions from your model, you must create at - * least one serving config or placement for it. For more information, see - * Manage serving configs - * (https://cloud.google.com/retail/docs/manage-configs). - * The full list of available serving configs can be seen at - * https://console.cloud.google.com/ai/retail/catalogs/default_catalog/configs - */ - // 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.v2alpha.UserEvent.visitor_id or - * UserInfo.user_id google.cloud.retail.v2alpha.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.v2alpha.UserEvent.visitor_id to - * a random unique ID and leave - * UserInfo.user_id google.cloud.retail.v2alpha.UserInfo.user_id unset. - */ - // const userEvent = {} - /** - * Maximum number of results to return. 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 - /** - * This field is not used; leave it unset. - */ - // 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 *no* - * results. If instead you want empty result sets to return generic - * (unfiltered) popular products, set `strictFiltering` to False in - * `PredictRequest.params`. Note that the API will never return items with - * storageStatus of "EXPIRED" or "DELETED" regardless of filter choices. - * If `filterSyntaxV2` is set to true under the `params` field, then - * attribute-based expressions are expected instead of the above described - * tag-based syntax. Examples: - * * (colors: ANY("Red", "Blue")) AND NOT (categories: ANY("Phones")) - * * (availability: ANY("IN_STOCK")) AND - * (colors: ANY("Red") OR categories: ANY("Phones")) - * For more information, see - * Filter recommendations (https://cloud.google.com/retail/docs/filter-recs). - */ - // 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 a 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. - * * `filterSyntaxV2`: Boolean. False by default. If set to true, the `filter` - * field is interpreteted according to the new, attribute-based syntax. - */ - // 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.add_fulfillment_places.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.add_fulfillment_places.js deleted file mode 100644 index dc07e51c740..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.add_fulfillment_places.js +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 google.cloud.retail.v2alpha.FulfillmentInfo.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/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.add_local_inventories.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.add_local_inventories.js deleted file mode 100644 index 08bd0ee5d9e..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.add_local_inventories.js +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.create_product.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.create_product.js deleted file mode 100644 index 7dc33678d7a..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.create_product.js +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.delete_product.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.delete_product.js deleted file mode 100644 index 9b4674a82e3..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.delete_product.js +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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' - /** - * This value only applies to the case when the target product is of type - * PRIMARY. - * When deleting a product of VARIANT/COLLECTION type, this value - * will be ignored. - * When set to true, the subsequent variant products will be - * deleted. - * When set to false, if the primary product has active variant products, an - * error will be returned. - */ - // const force = true - - // 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.get_product.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.get_product.js deleted file mode 100644 index 7a5236a0119..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.get_product.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.import_products.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.import_products.js deleted file mode 100644 index 40eba2dd035..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.import_products.js +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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, all fields are updated. - */ - // 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 = {} - /** - * Full Pub/Sub topic name for receiving notification. If this field is set, - * when the import is finished, a notification is sent to - * specified Pub/Sub topic. The message data is 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.v2alpha.ImportProductsRequest.parent. - * Make sure that `service-@gcp-sa-retail.iam.gserviceaccount.com` has the - * `pubsub.topics.publish` IAM permission on the topic. - */ - // const notificationPubsubTopic = 'abc123' - /** - * If true, this performs the FULL import even if it would delete a large - * proportion of the products in the default branch, which could potentially - * cause outages if you have live predict/search traffic. - * Only supported when - * ImportProductsRequest.reconciliation_mode google.cloud.retail.v2alpha.ImportProductsRequest.reconciliation_mode - * is set to `FULL`. - */ - // const skipDefaultBranchProtection = true - - // 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.list_products.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.list_products.js deleted file mode 100644 index 4f5f5f4f683..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.list_products.js +++ /dev/null @@ -1,144 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.purge_products.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.purge_products.js deleted file mode 100644 index a2048e8c732..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.purge_products.js +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.remove_fulfillment_places.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.remove_fulfillment_places.js deleted file mode 100644 index 7b428a62505..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.remove_fulfillment_places.js +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 google.cloud.retail.v2alpha.FulfillmentInfo.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/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.remove_local_inventories.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.remove_local_inventories.js deleted file mode 100644 index 4ccae287ae8..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.remove_local_inventories.js +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.set_inventory.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.set_inventory.js deleted file mode 100644 index e283078fe37..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.set_inventory.js +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 google.cloud.retail.v2alpha.Product.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 google.cloud.retail.v2alpha.Product.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 google.cloud.retail.v2alpha.Product.fulfillment_info - * * Checks that only the desired fulfillment info types have empty - * SetInventoryRequest.inventory.fulfillment_info.place_ids google.cloud.retail.v2alpha.FulfillmentInfo.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, - * ProductService.UpdateProduct google.cloud.retail.v2alpha.ProductService.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/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.update_product.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.update_product.js deleted file mode 100644 index 6ea3f997089..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/product_service.update_product.js +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The product 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. - * 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.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/google-cloud-retail/v2alpha/samples/generated/v2alpha/search_service.search.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/search_service.search.js deleted file mode 100644 index eda0a647bf0..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/search_service.search.js +++ /dev/null @@ -1,332 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the Retail Search serving config, such as - * `projects/* /locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` - * or the name of the legacy placement resource, such as - * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. - * This field is used to identify the serving config 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.v2alpha.SearchRequest.filter and - * page_categories google.cloud.retail.v2alpha.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.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 200 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 google.cloud.retail.v2alpha.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.local_inventories.attributes google.cloud.retail.v2alpha.LocalInventory.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. Must be set 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, 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. - * Notice that if both - * ServingConfig.personalization_spec google.cloud.retail.v2alpha.ServingConfig.personalization_spec - * and - * SearchRequest.personalization_spec google.cloud.retail.v2alpha.SearchRequest.personalization_spec - * are set. - * SearchRequest.personalization_spec google.cloud.retail.v2alpha.SearchRequest.personalization_spec - * will override - * ServingConfig.personalization_spec google.cloud.retail.v2alpha.ServingConfig.personalization_spec. - */ - // 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 = {} - /** - * The entity for customers that may run multiple different entities, domains, - * sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, - * `google.com`, `youtube.com`, etc. - * If this is set, it should be exactly matched with - * UserEvent.entity google.cloud.retail.v2alpha.UserEvent.entity to get - * search results boosted by entity. - */ - // const entity = 'abc123' - - // 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.add_control.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.add_control.js deleted file mode 100644 index 22f78550d0c..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.add_control.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.create_serving_config.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.create_serving_config.js deleted file mode 100644 index fc644a3a6a9..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.create_serving_config.js +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.delete_serving_config.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.delete_serving_config.js deleted file mode 100644 index 5c405e74f43..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.delete_serving_config.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.get_serving_config.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.get_serving_config.js deleted file mode 100644 index 32e33502e80..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.get_serving_config.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.list_serving_configs.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.list_serving_configs.js deleted file mode 100644 index 47b48b2b327..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.list_serving_configs.js +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.remove_control.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.remove_control.js deleted file mode 100644 index d5ee628f5a6..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.remove_control.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.update_serving_config.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.update_serving_config.js deleted file mode 100644 index 7d7404c54e3..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/serving_config_service.update_serving_config.js +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/snippet_metadata.google.cloud.retail.v2alpha.json b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/snippet_metadata.google.cloud.retail.v2alpha.json deleted file mode 100644 index d120273a41b..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/snippet_metadata.google.cloud.retail.v2alpha.json +++ /dev/null @@ -1,2735 +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": 78, - "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": 65, - "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": 76, - "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": 53, - "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": 54, - "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": 70, - "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": 54, - "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": 62, - "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": 60, - "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": 60, - "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_BatchRemoveCatalogAttributes_async", - "title": "CatalogService batchRemoveCatalogAttributes Sample", - "origin": "API_DEFINITION", - "description": " Removes all specified [CatalogAttribute][google.cloud.retail.v2alpha.CatalogAttribute]s from the [AttributesConfig][google.cloud.retail.v2alpha.AttributesConfig].", - "canonical": true, - "file": "catalog_service.batch_remove_catalog_attributes.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "BatchRemoveCatalogAttributes", - "fullName": "google.cloud.retail.v2alpha.CatalogService.BatchRemoveCatalogAttributes", - "async": true, - "parameters": [ - { - "name": "attributes_config", - "type": "TYPE_STRING" - }, - { - "name": "attribute_keys", - "type": "TYPE_STRING[]" - } - ], - "resultType": ".google.cloud.retail.v2alpha.BatchRemoveCatalogAttributesResponse", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2alpha.CatalogServiceClient" - }, - "method": { - "shortName": "BatchRemoveCatalogAttributes", - "fullName": "google.cloud.retail.v2alpha.CatalogService.BatchRemoveCatalogAttributes", - "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": 68, - "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. Enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "completion_service.complete_query.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 129, - "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" - }, - { - "name": "enable_attribute_suggestions", - "type": "TYPE_BOOL" - }, - { - "name": "entity", - "type": "TYPE_STRING" - } - ], - "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. 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": 68, - "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": 67, - "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": 54, - "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 update does not exist, a NOT_FOUND error is returned.", - "canonical": true, - "file": "control_service.update_control.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 61, - "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": 54, - "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 by their parent [Catalog][google.cloud.retail.v2alpha.Catalog].", - "canonical": true, - "file": "control_service.list_controls.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 74, - "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_MerchantCenterAccountLinkService_ListMerchantCenterAccountLinks_async", - "title": "CatalogService listMerchantCenterAccountLinks Sample", - "origin": "API_DEFINITION", - "description": " Lists all [MerchantCenterAccountLink][google.cloud.retail.v2alpha.MerchantCenterAccountLink]s under the specified parent [Catalog][google.cloud.retail.v2alpha.Catalog].", - "canonical": true, - "file": "merchant_center_account_link_service.list_merchant_center_account_links.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListMerchantCenterAccountLinks", - "fullName": "google.cloud.retail.v2alpha.MerchantCenterAccountLinkService.ListMerchantCenterAccountLinks", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2alpha.ListMerchantCenterAccountLinksResponse", - "client": { - "shortName": "MerchantCenterAccountLinkServiceClient", - "fullName": "google.cloud.retail.v2alpha.MerchantCenterAccountLinkServiceClient" - }, - "method": { - "shortName": "ListMerchantCenterAccountLinks", - "fullName": "google.cloud.retail.v2alpha.MerchantCenterAccountLinkService.ListMerchantCenterAccountLinks", - "service": { - "shortName": "MerchantCenterAccountLinkService", - "fullName": "google.cloud.retail.v2alpha.MerchantCenterAccountLinkService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_MerchantCenterAccountLinkService_CreateMerchantCenterAccountLink_async", - "title": "CatalogService createMerchantCenterAccountLink Sample", - "origin": "API_DEFINITION", - "description": " Creates a [MerchantCenterAccountLink][google.cloud.retail.v2alpha.MerchantCenterAccountLink].", - "canonical": true, - "file": "merchant_center_account_link_service.create_merchant_center_account_link.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateMerchantCenterAccountLink", - "fullName": "google.cloud.retail.v2alpha.MerchantCenterAccountLinkService.CreateMerchantCenterAccountLink", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "merchant_center_account_link", - "type": ".google.cloud.retail.v2alpha.MerchantCenterAccountLink" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "MerchantCenterAccountLinkServiceClient", - "fullName": "google.cloud.retail.v2alpha.MerchantCenterAccountLinkServiceClient" - }, - "method": { - "shortName": "CreateMerchantCenterAccountLink", - "fullName": "google.cloud.retail.v2alpha.MerchantCenterAccountLinkService.CreateMerchantCenterAccountLink", - "service": { - "shortName": "MerchantCenterAccountLinkService", - "fullName": "google.cloud.retail.v2alpha.MerchantCenterAccountLinkService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_MerchantCenterAccountLinkService_DeleteMerchantCenterAccountLink_async", - "title": "CatalogService deleteMerchantCenterAccountLink Sample", - "origin": "API_DEFINITION", - "description": " Deletes a [MerchantCenterAccountLink][google.cloud.retail.v2alpha.MerchantCenterAccountLink]. If the [MerchantCenterAccountLink][google.cloud.retail.v2alpha.MerchantCenterAccountLink] to delete does not exist, a NOT_FOUND error is returned.", - "canonical": true, - "file": "merchant_center_account_link_service.delete_merchant_center_account_link.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 54, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteMerchantCenterAccountLink", - "fullName": "google.cloud.retail.v2alpha.MerchantCenterAccountLinkService.DeleteMerchantCenterAccountLink", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "MerchantCenterAccountLinkServiceClient", - "fullName": "google.cloud.retail.v2alpha.MerchantCenterAccountLinkServiceClient" - }, - "method": { - "shortName": "DeleteMerchantCenterAccountLink", - "fullName": "google.cloud.retail.v2alpha.MerchantCenterAccountLinkService.DeleteMerchantCenterAccountLink", - "service": { - "shortName": "MerchantCenterAccountLinkService", - "fullName": "google.cloud.retail.v2alpha.MerchantCenterAccountLinkService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ModelService_CreateModel_async", - "title": "CatalogService createModel Sample", - "origin": "API_DEFINITION", - "description": " Creates a new model.", - "canonical": true, - "file": "model_service.create_model.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateModel", - "fullName": "google.cloud.retail.v2alpha.ModelService.CreateModel", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "model", - "type": ".google.cloud.retail.v2alpha.Model" - }, - { - "name": "dry_run", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ModelServiceClient", - "fullName": "google.cloud.retail.v2alpha.ModelServiceClient" - }, - "method": { - "shortName": "CreateModel", - "fullName": "google.cloud.retail.v2alpha.ModelService.CreateModel", - "service": { - "shortName": "ModelService", - "fullName": "google.cloud.retail.v2alpha.ModelService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ModelService_GetModel_async", - "title": "CatalogService getModel Sample", - "origin": "API_DEFINITION", - "description": " Gets a model.", - "canonical": true, - "file": "model_service.get_model.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetModel", - "fullName": "google.cloud.retail.v2alpha.ModelService.GetModel", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2alpha.Model", - "client": { - "shortName": "ModelServiceClient", - "fullName": "google.cloud.retail.v2alpha.ModelServiceClient" - }, - "method": { - "shortName": "GetModel", - "fullName": "google.cloud.retail.v2alpha.ModelService.GetModel", - "service": { - "shortName": "ModelService", - "fullName": "google.cloud.retail.v2alpha.ModelService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ModelService_PauseModel_async", - "title": "CatalogService pauseModel Sample", - "origin": "API_DEFINITION", - "description": " Pauses the training of an existing model.", - "canonical": true, - "file": "model_service.pause_model.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "PauseModel", - "fullName": "google.cloud.retail.v2alpha.ModelService.PauseModel", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2alpha.Model", - "client": { - "shortName": "ModelServiceClient", - "fullName": "google.cloud.retail.v2alpha.ModelServiceClient" - }, - "method": { - "shortName": "PauseModel", - "fullName": "google.cloud.retail.v2alpha.ModelService.PauseModel", - "service": { - "shortName": "ModelService", - "fullName": "google.cloud.retail.v2alpha.ModelService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ModelService_ResumeModel_async", - "title": "CatalogService resumeModel Sample", - "origin": "API_DEFINITION", - "description": " Resumes the training of an existing model.", - "canonical": true, - "file": "model_service.resume_model.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ResumeModel", - "fullName": "google.cloud.retail.v2alpha.ModelService.ResumeModel", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2alpha.Model", - "client": { - "shortName": "ModelServiceClient", - "fullName": "google.cloud.retail.v2alpha.ModelServiceClient" - }, - "method": { - "shortName": "ResumeModel", - "fullName": "google.cloud.retail.v2alpha.ModelService.ResumeModel", - "service": { - "shortName": "ModelService", - "fullName": "google.cloud.retail.v2alpha.ModelService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ModelService_DeleteModel_async", - "title": "CatalogService deleteModel Sample", - "origin": "API_DEFINITION", - "description": " Deletes an existing model.", - "canonical": true, - "file": "model_service.delete_model.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteModel", - "fullName": "google.cloud.retail.v2alpha.ModelService.DeleteModel", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ModelServiceClient", - "fullName": "google.cloud.retail.v2alpha.ModelServiceClient" - }, - "method": { - "shortName": "DeleteModel", - "fullName": "google.cloud.retail.v2alpha.ModelService.DeleteModel", - "service": { - "shortName": "ModelService", - "fullName": "google.cloud.retail.v2alpha.ModelService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ModelService_ListModels_async", - "title": "CatalogService listModels Sample", - "origin": "API_DEFINITION", - "description": " Lists all the models linked to this event store.", - "canonical": true, - "file": "model_service.list_models.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListModels", - "fullName": "google.cloud.retail.v2alpha.ModelService.ListModels", - "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.ListModelsResponse", - "client": { - "shortName": "ModelServiceClient", - "fullName": "google.cloud.retail.v2alpha.ModelServiceClient" - }, - "method": { - "shortName": "ListModels", - "fullName": "google.cloud.retail.v2alpha.ModelService.ListModels", - "service": { - "shortName": "ModelService", - "fullName": "google.cloud.retail.v2alpha.ModelService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ModelService_UpdateModel_async", - "title": "CatalogService updateModel Sample", - "origin": "API_DEFINITION", - "description": " Update of model metadata. Only fields that currently can be updated are: `filtering_option` and `periodic_tuning_state`. If other values are provided, this API method ignores them.", - "canonical": true, - "file": "model_service.update_model.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateModel", - "fullName": "google.cloud.retail.v2alpha.ModelService.UpdateModel", - "async": true, - "parameters": [ - { - "name": "model", - "type": ".google.cloud.retail.v2alpha.Model" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.retail.v2alpha.Model", - "client": { - "shortName": "ModelServiceClient", - "fullName": "google.cloud.retail.v2alpha.ModelServiceClient" - }, - "method": { - "shortName": "UpdateModel", - "fullName": "google.cloud.retail.v2alpha.ModelService.UpdateModel", - "service": { - "shortName": "ModelService", - "fullName": "google.cloud.retail.v2alpha.ModelService" - } - } - } - }, - { - "regionTag": "retail_v2alpha_generated_ModelService_TuneModel_async", - "title": "CatalogService tuneModel Sample", - "origin": "API_DEFINITION", - "description": " Tunes an existing model.", - "canonical": true, - "file": "model_service.tune_model.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 56, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "TuneModel", - "fullName": "google.cloud.retail.v2alpha.ModelService.TuneModel", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ModelServiceClient", - "fullName": "google.cloud.retail.v2alpha.ModelServiceClient" - }, - "method": { - "shortName": "TuneModel", - "fullName": "google.cloud.retail.v2alpha.ModelService.TuneModel", - "service": { - "shortName": "ModelService", - "fullName": "google.cloud.retail.v2alpha.ModelService" - } - } - } - }, - { - "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": 179, - "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": 75, - "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": 60, - "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": 136, - "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": 79, - "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": 81, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteProduct", - "fullName": "google.cloud.retail.v2alpha.ProductService.DeleteProduct", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "force", - "type": "TYPE_BOOL" - } - ], - "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 [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or [ProductService.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": 96, - "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. 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": 99, - "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" - }, - { - "name": "skip_default_branch_protection", - "type": "TYPE_BOOL" - } - ], - "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 is 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 [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. When inventory is updated with [ProductService.CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] and [ProductService.UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct], the specified inventory field value(s) overwrite any existing value(s) while ignoring the last update time for this field. Furthermore, the last update times for the specified inventory fields are overwritten by the times of the [ProductService.CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] or [ProductService.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 is used. If no inventory fields are set in [SetInventoryRequest.set_mask][google.cloud.retail.v2alpha.SetInventoryRequest.set_mask], then any existing inventory information is preserved. Pre-existing inventory information can only be updated with [ProductService.SetInventory][google.cloud.retail.v2alpha.ProductService.SetInventory], [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlaces], and [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces]. The returned [Operation][google.longrunning.Operation]s is obsolete after one day, and the [GetOperation][google.longrunning.Operations.GetOperation] API returns `NOT_FOUND` afterwards. If conflicting updates are issued, the [Operation][google.longrunning.Operation]s associated with the stale updates are not marked as [done][google.longrunning.Operation.done] until they are obsolete.", - "canonical": true, - "file": "product_service.set_inventory.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 123, - "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": " It is recommended to use the [ProductService.AddLocalInventories][google.cloud.retail.v2alpha.ProductService.AddLocalInventories] method instead of [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlaces]. [ProductService.AddLocalInventories][google.cloud.retail.v2alpha.ProductService.AddLocalInventories] achieves the same results but provides more fine-grained control over ingesting local inventory data. 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 [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. The returned [Operation][google.longrunning.Operation]s will be obsolete after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] API will return NOT_FOUND afterwards. If conflicting updates are issued, the [Operation][google.longrunning.Operation]s associated with the stale updates will not be marked as [done][google.longrunning.Operation.done] until being obsolete.", - "canonical": true, - "file": "product_service.add_fulfillment_places.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 111, - "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": " It is recommended to use the [ProductService.RemoveLocalInventories][google.cloud.retail.v2alpha.ProductService.RemoveLocalInventories] method instead of [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces]. [ProductService.RemoveLocalInventories][google.cloud.retail.v2alpha.ProductService.RemoveLocalInventories] achieves the same results but provides more fine-grained control over ingesting local inventory data. 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 [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. The returned [Operation][google.longrunning.Operation]s will be obsolete after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] API will return NOT_FOUND afterwards. If conflicting updates are issued, the [Operation][google.longrunning.Operation]s associated with the stale updates will not be marked as [done][google.longrunning.Operation.done] until being obsolete.", - "canonical": true, - "file": "product_service.remove_fulfillment_places.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 107, - "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 [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. Local inventory information can only be modified using this method. [ProductService.CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] and [ProductService.UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct] has no effect on local inventories. The returned [Operation][google.longrunning.Operation]s will be obsolete after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] API will return NOT_FOUND afterwards. If conflicting updates are issued, the [Operation][google.longrunning.Operation]s associated with the stale updates will not be marked as [done][google.longrunning.Operation.done] until being obsolete.", - "canonical": true, - "file": "product_service.add_local_inventories.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 95, - "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 [ProductService.GetProduct][google.cloud.retail.v2alpha.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2alpha.ProductService.ListProducts]. Local inventory information can only be removed using this method. [ProductService.CreateProduct][google.cloud.retail.v2alpha.ProductService.CreateProduct] and [ProductService.UpdateProduct][google.cloud.retail.v2alpha.ProductService.UpdateProduct] has no effect on local inventories. The returned [Operation][google.longrunning.Operation]s will be obsolete after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] API will return NOT_FOUND afterwards. If conflicting updates are issued, the [Operation][google.longrunning.Operation]s associated with the stale updates will not be marked as [done][google.longrunning.Operation.done] until being obsolete.", - "canonical": true, - "file": "product_service.remove_local_inventories.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 80, - "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. Enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "search_service.search.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 324, - "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" - }, - { - "name": "labels", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "spell_correction_spec", - "type": ".google.cloud.retail.v2alpha.SearchRequest.SpellCorrectionSpec" - }, - { - "name": "entity", - "type": "TYPE_STRING" - } - ], - "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": 67, - "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": 54, - "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": 61, - "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": 54, - "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": 67, - "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": 60, - "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": 60, - "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": 66, - "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" - }, - { - "name": "write_async", - "type": "TYPE_BOOL" - } - ], - "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": 85, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CollectUserEvent", - "fullName": "google.cloud.retail.v2alpha.UserEventService.CollectUserEvent", - "async": true, - "parameters": [ - { - "name": "prebuilt_rule", - "type": "TYPE_STRING" - }, - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "user_event", - "type": "TYPE_STRING" - }, - { - "name": "uri", - "type": "TYPE_STRING" - }, - { - "name": "ets", - "type": "TYPE_INT64" - }, - { - "name": "raw_json", - "type": "TYPE_STRING" - } - ], - "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": 86, - "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": 64, - "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 are not annotated with detailed product information for products that are missing from the catalog when the user event is ingested. These events are stored as unjoined events with limited usage on training and serving. You can use this method to start a join operation on specified events with the latest version of product catalog. You can also use this method 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": 62, - "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/google-cloud-retail/v2alpha/samples/generated/v2alpha/user_event_service.collect_user_event.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/user_event_service.collect_user_event.js deleted file mode 100644 index 165f42f95e8..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/user_event_service.collect_user_event.js +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * The prebuilt rule name that can convert a specific type of raw_json. - * For example: "ga4_bq" rule for the GA4 user event schema. - */ - // const prebuiltRule = 'abc123' - /** - * 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 - /** - * An arbitrary serialized JSON string that contains necessary information - * that can comprise a user event. When this field is specified, the - * user_event field will be ignored. Note: line-delimited JSON is not - * supported, a single JSON only. - */ - // const rawJson = 'abc123' - - // 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/user_event_service.import_user_events.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/user_event_service.import_user_events.js deleted file mode 100644 index ab0256d3fac..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/user_event_service.import_user_events.js +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/user_event_service.purge_user_events.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/user_event_service.purge_user_events.js deleted file mode 100644 index c68f97440e7..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/user_event_service.purge_user_events.js +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/user_event_service.rejoin_user_events.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/user_event_service.rejoin_user_events.js deleted file mode 100644 index 5bb701e438b..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/user_event_service.rejoin_user_events.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent 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/google-cloud-retail/v2alpha/samples/generated/v2alpha/user_event_service.write_user_event.js b/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/user_event_service.write_user_event.js deleted file mode 100644 index 6e9588f1a75..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/samples/generated/v2alpha/user_event_service.write_user_event.js +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent catalog resource name, such as - * `projects/1234/locations/global/catalogs/default_catalog`. - */ - // const parent = 'abc123' - /** - * Required. User event to write. - */ - // const userEvent = {} - /** - * If set to true, the user event will be written asynchronously after - * validation, and the API will respond without waiting for the write. - * Therefore, silent failures can occur even if the API returns success. In - * case of silent failures, error messages can be found in Stackdriver logs. - */ - // const writeAsync = true - - // 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/google-cloud-retail/v2alpha/src/index.ts b/owl-bot-staging/google-cloud-retail/v2alpha/src/index.ts deleted file mode 100644 index 83d1892f5b7..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/src/index.ts +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This 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 MerchantCenterAccountLinkServiceClient = v2alpha.MerchantCenterAccountLinkServiceClient; -type MerchantCenterAccountLinkServiceClient = v2alpha.MerchantCenterAccountLinkServiceClient; -const ModelServiceClient = v2alpha.ModelServiceClient; -type ModelServiceClient = v2alpha.ModelServiceClient; -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, MerchantCenterAccountLinkServiceClient, ModelServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, ServingConfigServiceClient, UserEventServiceClient}; -export default {v2alpha, CatalogServiceClient, CompletionServiceClient, ControlServiceClient, MerchantCenterAccountLinkServiceClient, ModelServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, ServingConfigServiceClient, UserEventServiceClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/catalog_service_client.ts b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/catalog_service_client.ts deleted file mode 100644 index b85b0bf2d0e..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/catalog_service_client.ts +++ /dev/null @@ -1,2369 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/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}; - locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - 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/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new CatalogServiceClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof 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); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - this.locationsClient = new this._gaxModule.LocationsClient( - this._gaxGrpc, - opts - ); - - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - 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}' - ), - merchantCenterAccountLinkPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/merchantCenterAccountLinks/{merchant_center_account_link}' - ), - modelPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' - ), - 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') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',additional_bindings: [{get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/places/*/operations/*}',},{get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2alpha/{name=projects/*/locations/*/operations/*}',},{get: '/v2alpha/{name=projects/*/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2alpha/{name=projects/*/locations/*/catalogs/*}/operations',additional_bindings: [{get: '/v2alpha/{name=projects/*/locations/*}/operations',},{get: '/v2alpha/{name=projects/*}/operations',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - - this.descriptors.longrunning = { - }; - - // 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 = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.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', 'batchRemoveCatalogAttributes', '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._opts.fallback - ); - - 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 {@link google.cloud.retail.v2alpha.Catalog | 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' - ] = this._gaxModule.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 {@link google.protobuf.Empty | 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' - ] = this._gaxModule.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 {@link google.cloud.retail.v2alpha.GetDefaultBranchResponse | 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' - ] = this._gaxModule.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 {@link google.cloud.retail.v2alpha.CompletionConfig | 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' - ] = this._gaxModule.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 {@link google.cloud.retail.v2alpha.CompletionConfig | 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' - ] = this._gaxModule.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 {@link google.cloud.retail.v2alpha.AttributesConfig | 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' - ] = this._gaxModule.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 {@link google.cloud.retail.v2alpha.AttributesConfig | 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' - ] = this._gaxModule.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 {@link google.cloud.retail.v2alpha.AttributesConfig | 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' - ] = this._gaxModule.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 {@link google.cloud.retail.v2alpha.AttributesConfig | 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'attributes_config': request.attributesConfig ?? '', - }); - this.initialize(); - return this.innerApiCalls.removeCatalogAttribute(request, options, callback); - } -/** - * Removes all specified - * {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute}s from the - * {@link google.cloud.retail.v2alpha.AttributesConfig|AttributesConfig}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.attributesConfig - * Required. The attributes config resource shared by all catalog attributes - * being deleted. Format: - * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` - * @param {string[]} request.attributeKeys - * Required. The attribute name keys of the - * {@link google.cloud.retail.v2alpha.CatalogAttribute|CatalogAttribute}s to - * delete. A maximum of 1000 catalog attributes can be deleted in a batch. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.retail.v2alpha.BatchRemoveCatalogAttributesResponse | BatchRemoveCatalogAttributesResponse}. - * Please see 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.batch_remove_catalog_attributes.js - * region_tag:retail_v2alpha_generated_CatalogService_BatchRemoveCatalogAttributes_async - */ - batchRemoveCatalogAttributes( - request?: protos.google.cloud.retail.v2alpha.IBatchRemoveCatalogAttributesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IBatchRemoveCatalogAttributesResponse, - protos.google.cloud.retail.v2alpha.IBatchRemoveCatalogAttributesRequest|undefined, {}|undefined - ]>; - batchRemoveCatalogAttributes( - request: protos.google.cloud.retail.v2alpha.IBatchRemoveCatalogAttributesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.IBatchRemoveCatalogAttributesResponse, - protos.google.cloud.retail.v2alpha.IBatchRemoveCatalogAttributesRequest|null|undefined, - {}|null|undefined>): void; - batchRemoveCatalogAttributes( - request: protos.google.cloud.retail.v2alpha.IBatchRemoveCatalogAttributesRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.IBatchRemoveCatalogAttributesResponse, - protos.google.cloud.retail.v2alpha.IBatchRemoveCatalogAttributesRequest|null|undefined, - {}|null|undefined>): void; - batchRemoveCatalogAttributes( - request?: protos.google.cloud.retail.v2alpha.IBatchRemoveCatalogAttributesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.IBatchRemoveCatalogAttributesResponse, - protos.google.cloud.retail.v2alpha.IBatchRemoveCatalogAttributesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.IBatchRemoveCatalogAttributesResponse, - protos.google.cloud.retail.v2alpha.IBatchRemoveCatalogAttributesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.IBatchRemoveCatalogAttributesResponse, - protos.google.cloud.retail.v2alpha.IBatchRemoveCatalogAttributesRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'attributes_config': request.attributesConfig ?? '', - }); - this.initialize(); - return this.innerApiCalls.batchRemoveCatalogAttributes(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 {@link google.cloud.retail.v2alpha.AttributesConfig | 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' - ] = this._gaxModule.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 {@link google.cloud.retail.v2alpha.Catalog | 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' - ] = this._gaxModule.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 {@link google.cloud.retail.v2alpha.Catalog | 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' - ] = this._gaxModule.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 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 - * {@link google.cloud.retail.v2alpha.Catalog | 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' - ] = this._gaxModule.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 {}, - callSettings - ) as AsyncIterable; - } -/** - * Gets information about a location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Resource name for the location. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * ``` - * const [response] = await client.getLocation(request); - * ``` - */ - getLocation( - request: LocationProtos.google.cloud.location.IGetLocationRequest, - options?: - | gax.CallOptions - | Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - > - ): Promise { - return this.locationsClient.getLocation(request, options, callback); - } - -/** - * Lists information about the supported locations for this service. Returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The resource that owns the locations collection, if applicable. - * @param {string} request.filter - * The standard list filter. - * @param {number} request.pageSize - * The standard list page size. - * @param {string} request.pageToken - * The standard list page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example - * ``` - * const iterable = client.listLocationsAsync(request); - * for await (const response of iterable) { - * // process response - * } - * ``` - */ - listLocationsAsync( - request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions - ): AsyncIterable { - return this.locationsClient.listLocationsAsync(request, options); - } - -/** - * Gets the latest state of a long-running operation. Clients can use this - * method to poll the operation result at intervals as recommended by the API - * service. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error, ?Object)=} callback - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * const name = ''; - * const [response] = await client.getOperation({name}); - * // doThingsWith(response) - * ``` - */ - getOperation( - request: protos.google.longrunning.GetOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - > - ): Promise<[protos.google.longrunning.Operation]> { - return this.operationsClient.getOperation(request, options, callback); - } - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. - * - * For-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation collection. - * @param {string} request.filter - The standard list filter. - * @param {number=} request.pageSize - - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @returns {Object} - * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * for await (const response of client.listOperationsAsync(request)); - * // doThingsWith(response) - * ``` - */ - listOperationsAsync( - request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions - ): AsyncIterable { - return this.operationsClient.listOperationsAsync(request, options); - } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * {@link Operations.GetOperation} or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an {@link Operation.error} value with a {@link google.rpc.Status.code} of - * 1, corresponding to `Code.CANCELLED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be cancelled. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.cancelOperation({name: ''}); - * ``` - */ - cancelOperation( - request: protos.google.longrunning.CancelOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.CancelOperationRequest, - {} | undefined | null - >, - callback?: Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - > - ): Promise { - return this.operationsClient.cancelOperation(request, options, callback); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be deleted. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.deleteOperation({name: ''}); - * ``` - */ - deleteOperation( - request: protos.google.longrunning.DeleteOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - > - ): Promise { - return this.operationsClient.deleteOperation(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified 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 merchantCenterAccountLink resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} merchant_center_account_link - * @returns {string} Resource name string. - */ - merchantCenterAccountLinkPath(project:string,location:string,catalog:string,merchantCenterAccountLink:string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - merchant_center_account_link: merchantCenterAccountLink, - }); - } - - /** - * Parse the project from MerchantCenterAccountLink resource. - * - * @param {string} merchantCenterAccountLinkName - * A fully-qualified path representing MerchantCenterAccountLink resource. - * @returns {string} A string representing the project. - */ - matchProjectFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).project; - } - - /** - * Parse the location from MerchantCenterAccountLink resource. - * - * @param {string} merchantCenterAccountLinkName - * A fully-qualified path representing MerchantCenterAccountLink resource. - * @returns {string} A string representing the location. - */ - matchLocationFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).location; - } - - /** - * Parse the catalog from MerchantCenterAccountLink resource. - * - * @param {string} merchantCenterAccountLinkName - * A fully-qualified path representing MerchantCenterAccountLink resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).catalog; - } - - /** - * Parse the merchant_center_account_link from MerchantCenterAccountLink resource. - * - * @param {string} merchantCenterAccountLinkName - * A fully-qualified path representing MerchantCenterAccountLink resource. - * @returns {string} A string representing the merchant_center_account_link. - */ - matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).merchant_center_account_link; - } - - /** - * Return a fully-qualified model resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} model - * @returns {string} Resource name string. - */ - modelPath(project:string,location:string,catalog:string,model:string) { - return this.pathTemplates.modelPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - model: model, - }); - } - - /** - * Parse the project from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the project. - */ - matchProjectFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).project; - } - - /** - * Parse the location from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the location. - */ - matchLocationFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).location; - } - - /** - * Parse the catalog from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).catalog; - } - - /** - * Parse the model from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the model. - */ - matchModelFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).model; - } - - /** - * 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(); - this.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/catalog_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/catalog_service_client_config.json deleted file mode 100644 index 430dc2ec64e..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/catalog_service_client_config.json +++ /dev/null @@ -1,95 +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" - }, - "BatchRemoveCatalogAttributes": { - "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/google-cloud-retail/v2alpha/src/v2alpha/catalog_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/catalog_service_proto_list.json deleted file mode 100644 index b794e38509a..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/catalog_service_proto_list.json +++ /dev/null @@ -1,24 +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/merchant_center_account_link.proto", - "../../protos/google/cloud/retail/v2alpha/merchant_center_account_link_service.proto", - "../../protos/google/cloud/retail/v2alpha/model.proto", - "../../protos/google/cloud/retail/v2alpha/model_service.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/google-cloud-retail/v2alpha/src/v2alpha/completion_service_client.ts b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/completion_service_client.ts deleted file mode 100644 index 2c00d3a878c..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/completion_service_client.ts +++ /dev/null @@ -1,1363 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, LocationsClient, LocationProtos} 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'; -const version = require('../../../package.json').version; - -/** - * Autocomplete service for retail. - * - * This feature is only available for users who have Retail Search enabled. - * 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}; - locationsClient: LocationsClient; - 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/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new CompletionServiceClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof 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); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - this.locationsClient = new this._gaxModule.LocationsClient( - this._gaxGrpc, - opts - ); - - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - 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}' - ), - merchantCenterAccountLinkPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/merchantCenterAccountLinks/{merchant_center_account_link}' - ), - modelPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' - ), - 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. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',additional_bindings: [{get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/places/*/operations/*}',},{get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2alpha/{name=projects/*/locations/*/operations/*}',},{get: '/v2alpha/{name=projects/*/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2alpha/{name=projects/*/locations/*/catalogs/*}/operations',additional_bindings: [{get: '/v2alpha/{name=projects/*/locations/*}/operations',},{get: '/v2alpha/{name=projects/*}/operations',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).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 = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.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._opts.fallback - ); - - 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. - * 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 - * Note that this field applies for `user-data` dataset only. For requests - * with `cloud-retail` dataset, setting this field has no effect. - * - * 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. We recommend that you - * leave this field empty. - * - * It can 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 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 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 {boolean} request.enableAttributeSuggestions - * If true, attribute suggestions are enabled and provided in response. - * - * This field is only available for "cloud-retail" dataset. - * @param {string} request.entity - * The entity for customers that may run multiple different entities, domains, - * sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, - * `google.com`, `youtube.com`, etc. - * If this is set, it should be exactly matched with - * {@link google.cloud.retail.v2alpha.UserEvent.entity|UserEvent.entity} to get - * per-entity autocomplete results. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.retail.v2alpha.CompleteQueryResponse | 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' - ] = this._gaxModule.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. - * 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 is sent to - * specified Pub/Sub topic. The message data is 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' - ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.importCompletionData, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Gets information about a location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Resource name for the location. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * ``` - * const [response] = await client.getLocation(request); - * ``` - */ - getLocation( - request: LocationProtos.google.cloud.location.IGetLocationRequest, - options?: - | gax.CallOptions - | Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - > - ): Promise { - return this.locationsClient.getLocation(request, options, callback); - } - -/** - * Lists information about the supported locations for this service. Returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The resource that owns the locations collection, if applicable. - * @param {string} request.filter - * The standard list filter. - * @param {number} request.pageSize - * The standard list page size. - * @param {string} request.pageToken - * The standard list page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example - * ``` - * const iterable = client.listLocationsAsync(request); - * for await (const response of iterable) { - * // process response - * } - * ``` - */ - listLocationsAsync( - request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions - ): AsyncIterable { - return this.locationsClient.listLocationsAsync(request, options); - } - -/** - * Gets the latest state of a long-running operation. Clients can use this - * method to poll the operation result at intervals as recommended by the API - * service. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error, ?Object)=} callback - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * const name = ''; - * const [response] = await client.getOperation({name}); - * // doThingsWith(response) - * ``` - */ - getOperation( - request: protos.google.longrunning.GetOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - > - ): Promise<[protos.google.longrunning.Operation]> { - return this.operationsClient.getOperation(request, options, callback); - } - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. - * - * For-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation collection. - * @param {string} request.filter - The standard list filter. - * @param {number=} request.pageSize - - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @returns {Object} - * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * for await (const response of client.listOperationsAsync(request)); - * // doThingsWith(response) - * ``` - */ - listOperationsAsync( - request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions - ): AsyncIterable { - return this.operationsClient.listOperationsAsync(request, options); - } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * {@link Operations.GetOperation} or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an {@link Operation.error} value with a {@link google.rpc.Status.code} of - * 1, corresponding to `Code.CANCELLED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be cancelled. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.cancelOperation({name: ''}); - * ``` - */ - cancelOperation( - request: protos.google.longrunning.CancelOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.CancelOperationRequest, - {} | undefined | null - >, - callback?: Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - > - ): Promise { - return this.operationsClient.cancelOperation(request, options, callback); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be deleted. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.deleteOperation({name: ''}); - * ``` - */ - deleteOperation( - request: protos.google.longrunning.DeleteOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - > - ): Promise { - return this.operationsClient.deleteOperation(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified 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 merchantCenterAccountLink resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} merchant_center_account_link - * @returns {string} Resource name string. - */ - merchantCenterAccountLinkPath(project:string,location:string,catalog:string,merchantCenterAccountLink:string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - merchant_center_account_link: merchantCenterAccountLink, - }); - } - - /** - * Parse the project from MerchantCenterAccountLink resource. - * - * @param {string} merchantCenterAccountLinkName - * A fully-qualified path representing MerchantCenterAccountLink resource. - * @returns {string} A string representing the project. - */ - matchProjectFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).project; - } - - /** - * Parse the location from MerchantCenterAccountLink resource. - * - * @param {string} merchantCenterAccountLinkName - * A fully-qualified path representing MerchantCenterAccountLink resource. - * @returns {string} A string representing the location. - */ - matchLocationFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).location; - } - - /** - * Parse the catalog from MerchantCenterAccountLink resource. - * - * @param {string} merchantCenterAccountLinkName - * A fully-qualified path representing MerchantCenterAccountLink resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).catalog; - } - - /** - * Parse the merchant_center_account_link from MerchantCenterAccountLink resource. - * - * @param {string} merchantCenterAccountLinkName - * A fully-qualified path representing MerchantCenterAccountLink resource. - * @returns {string} A string representing the merchant_center_account_link. - */ - matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).merchant_center_account_link; - } - - /** - * Return a fully-qualified model resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} model - * @returns {string} Resource name string. - */ - modelPath(project:string,location:string,catalog:string,model:string) { - return this.pathTemplates.modelPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - model: model, - }); - } - - /** - * Parse the project from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the project. - */ - matchProjectFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).project; - } - - /** - * Parse the location from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the location. - */ - matchLocationFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).location; - } - - /** - * Parse the catalog from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).catalog; - } - - /** - * Parse the model from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the model. - */ - matchModelFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).model; - } - - /** - * 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.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/completion_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/completion_service_client_config.json deleted file mode 100644 index ac2795a5fb1..00000000000 --- a/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2alpha/src/v2alpha/completion_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/completion_service_proto_list.json deleted file mode 100644 index b794e38509a..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/completion_service_proto_list.json +++ /dev/null @@ -1,24 +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/merchant_center_account_link.proto", - "../../protos/google/cloud/retail/v2alpha/merchant_center_account_link_service.proto", - "../../protos/google/cloud/retail/v2alpha/model.proto", - "../../protos/google/cloud/retail/v2alpha/model_service.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/google-cloud-retail/v2alpha/src/v2alpha/control_service_client.ts b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/control_service_client.ts deleted file mode 100644 index d866d6af200..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/control_service_client.ts +++ /dev/null @@ -1,1621 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/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}; - locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - 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/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new ControlServiceClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof 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); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - this.locationsClient = new this._gaxModule.LocationsClient( - this._gaxGrpc, - opts - ); - - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - 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}' - ), - merchantCenterAccountLinkPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/merchantCenterAccountLinks/{merchant_center_account_link}' - ), - modelPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' - ), - 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') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',additional_bindings: [{get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/places/*/operations/*}',},{get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2alpha/{name=projects/*/locations/*/operations/*}',},{get: '/v2alpha/{name=projects/*/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2alpha/{name=projects/*/locations/*/catalogs/*}/operations',additional_bindings: [{get: '/v2alpha/{name=projects/*/locations/*}/operations',},{get: '/v2alpha/{name=projects/*}/operations',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - - this.descriptors.longrunning = { - }; - - // 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 = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.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._opts.fallback - ); - - 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 {@link google.cloud.retail.v2alpha.Control | 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' - ] = this._gaxModule.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 {@link google.protobuf.Empty | 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' - ] = this._gaxModule.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 update 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 {@link google.cloud.retail.v2alpha.Control | 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' - ] = this._gaxModule.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 get. 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 {@link google.cloud.retail.v2alpha.Control | 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getControl(request, options, callback); - } - - /** - * Lists all Controls by their parent - * {@link google.cloud.retail.v2alpha.Catalog|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 {@link google.cloud.retail.v2alpha.Control | 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' - ] = this._gaxModule.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 {@link google.cloud.retail.v2alpha.Control | 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' - ] = this._gaxModule.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 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 - * {@link google.cloud.retail.v2alpha.Control | 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' - ] = this._gaxModule.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 {}, - callSettings - ) as AsyncIterable; - } -/** - * Gets information about a location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Resource name for the location. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * ``` - * const [response] = await client.getLocation(request); - * ``` - */ - getLocation( - request: LocationProtos.google.cloud.location.IGetLocationRequest, - options?: - | gax.CallOptions - | Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - > - ): Promise { - return this.locationsClient.getLocation(request, options, callback); - } - -/** - * Lists information about the supported locations for this service. Returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The resource that owns the locations collection, if applicable. - * @param {string} request.filter - * The standard list filter. - * @param {number} request.pageSize - * The standard list page size. - * @param {string} request.pageToken - * The standard list page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example - * ``` - * const iterable = client.listLocationsAsync(request); - * for await (const response of iterable) { - * // process response - * } - * ``` - */ - listLocationsAsync( - request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions - ): AsyncIterable { - return this.locationsClient.listLocationsAsync(request, options); - } - -/** - * Gets the latest state of a long-running operation. Clients can use this - * method to poll the operation result at intervals as recommended by the API - * service. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error, ?Object)=} callback - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * const name = ''; - * const [response] = await client.getOperation({name}); - * // doThingsWith(response) - * ``` - */ - getOperation( - request: protos.google.longrunning.GetOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - > - ): Promise<[protos.google.longrunning.Operation]> { - return this.operationsClient.getOperation(request, options, callback); - } - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. - * - * For-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation collection. - * @param {string} request.filter - The standard list filter. - * @param {number=} request.pageSize - - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @returns {Object} - * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * for await (const response of client.listOperationsAsync(request)); - * // doThingsWith(response) - * ``` - */ - listOperationsAsync( - request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions - ): AsyncIterable { - return this.operationsClient.listOperationsAsync(request, options); - } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * {@link Operations.GetOperation} or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an {@link Operation.error} value with a {@link google.rpc.Status.code} of - * 1, corresponding to `Code.CANCELLED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be cancelled. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.cancelOperation({name: ''}); - * ``` - */ - cancelOperation( - request: protos.google.longrunning.CancelOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.CancelOperationRequest, - {} | undefined | null - >, - callback?: Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - > - ): Promise { - return this.operationsClient.cancelOperation(request, options, callback); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be deleted. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.deleteOperation({name: ''}); - * ``` - */ - deleteOperation( - request: protos.google.longrunning.DeleteOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - > - ): Promise { - return this.operationsClient.deleteOperation(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified 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 merchantCenterAccountLink resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} merchant_center_account_link - * @returns {string} Resource name string. - */ - merchantCenterAccountLinkPath(project:string,location:string,catalog:string,merchantCenterAccountLink:string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - merchant_center_account_link: merchantCenterAccountLink, - }); - } - - /** - * Parse the project from MerchantCenterAccountLink resource. - * - * @param {string} merchantCenterAccountLinkName - * A fully-qualified path representing MerchantCenterAccountLink resource. - * @returns {string} A string representing the project. - */ - matchProjectFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).project; - } - - /** - * Parse the location from MerchantCenterAccountLink resource. - * - * @param {string} merchantCenterAccountLinkName - * A fully-qualified path representing MerchantCenterAccountLink resource. - * @returns {string} A string representing the location. - */ - matchLocationFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).location; - } - - /** - * Parse the catalog from MerchantCenterAccountLink resource. - * - * @param {string} merchantCenterAccountLinkName - * A fully-qualified path representing MerchantCenterAccountLink resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).catalog; - } - - /** - * Parse the merchant_center_account_link from MerchantCenterAccountLink resource. - * - * @param {string} merchantCenterAccountLinkName - * A fully-qualified path representing MerchantCenterAccountLink resource. - * @returns {string} A string representing the merchant_center_account_link. - */ - matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).merchant_center_account_link; - } - - /** - * Return a fully-qualified model resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} model - * @returns {string} Resource name string. - */ - modelPath(project:string,location:string,catalog:string,model:string) { - return this.pathTemplates.modelPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - model: model, - }); - } - - /** - * Parse the project from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the project. - */ - matchProjectFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).project; - } - - /** - * Parse the location from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the location. - */ - matchLocationFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).location; - } - - /** - * Parse the catalog from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).catalog; - } - - /** - * Parse the model from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the model. - */ - matchModelFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).model; - } - - /** - * 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(); - this.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/control_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/control_service_client_config.json deleted file mode 100644 index 9a86d786b23..00000000000 --- a/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2alpha/src/v2alpha/control_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/control_service_proto_list.json deleted file mode 100644 index b794e38509a..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/control_service_proto_list.json +++ /dev/null @@ -1,24 +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/merchant_center_account_link.proto", - "../../protos/google/cloud/retail/v2alpha/merchant_center_account_link_service.proto", - "../../protos/google/cloud/retail/v2alpha/model.proto", - "../../protos/google/cloud/retail/v2alpha/model_service.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/google-cloud-retail/v2alpha/src/v2alpha/gapic_metadata.json b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/gapic_metadata.json deleted file mode 100644 index 0c8eeb47a17..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/gapic_metadata.json +++ /dev/null @@ -1,733 +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" - ] - }, - "BatchRemoveCatalogAttributes": { - "methods": [ - "batchRemoveCatalogAttributes" - ] - }, - "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" - ] - }, - "BatchRemoveCatalogAttributes": { - "methods": [ - "batchRemoveCatalogAttributes" - ] - }, - "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" - ] - } - } - } - } - }, - "MerchantCenterAccountLinkService": { - "clients": { - "grpc": { - "libraryClient": "MerchantCenterAccountLinkServiceClient", - "rpcs": { - "ListMerchantCenterAccountLinks": { - "methods": [ - "listMerchantCenterAccountLinks" - ] - }, - "DeleteMerchantCenterAccountLink": { - "methods": [ - "deleteMerchantCenterAccountLink" - ] - }, - "CreateMerchantCenterAccountLink": { - "methods": [ - "createMerchantCenterAccountLink" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "MerchantCenterAccountLinkServiceClient", - "rpcs": { - "ListMerchantCenterAccountLinks": { - "methods": [ - "listMerchantCenterAccountLinks" - ] - }, - "DeleteMerchantCenterAccountLink": { - "methods": [ - "deleteMerchantCenterAccountLink" - ] - }, - "CreateMerchantCenterAccountLink": { - "methods": [ - "createMerchantCenterAccountLink" - ] - } - } - } - } - }, - "ModelService": { - "clients": { - "grpc": { - "libraryClient": "ModelServiceClient", - "rpcs": { - "GetModel": { - "methods": [ - "getModel" - ] - }, - "PauseModel": { - "methods": [ - "pauseModel" - ] - }, - "ResumeModel": { - "methods": [ - "resumeModel" - ] - }, - "DeleteModel": { - "methods": [ - "deleteModel" - ] - }, - "UpdateModel": { - "methods": [ - "updateModel" - ] - }, - "CreateModel": { - "methods": [ - "createModel" - ] - }, - "TuneModel": { - "methods": [ - "tuneModel" - ] - }, - "ListModels": { - "methods": [ - "listModels", - "listModelsStream", - "listModelsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ModelServiceClient", - "rpcs": { - "GetModel": { - "methods": [ - "getModel" - ] - }, - "PauseModel": { - "methods": [ - "pauseModel" - ] - }, - "ResumeModel": { - "methods": [ - "resumeModel" - ] - }, - "DeleteModel": { - "methods": [ - "deleteModel" - ] - }, - "UpdateModel": { - "methods": [ - "updateModel" - ] - }, - "CreateModel": { - "methods": [ - "createModel" - ] - }, - "TuneModel": { - "methods": [ - "tuneModel" - ] - }, - "ListModels": { - "methods": [ - "listModels", - "listModelsStream", - "listModelsAsync" - ] - } - } - } - } - }, - "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/google-cloud-retail/v2alpha/src/v2alpha/index.ts b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/index.ts deleted file mode 100644 index 2dbce074db8..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/index.ts +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** 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 {MerchantCenterAccountLinkServiceClient} from './merchant_center_account_link_service_client'; -export {ModelServiceClient} from './model_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/google-cloud-retail/v2alpha/src/v2alpha/merchant_center_account_link_service_client.ts b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/merchant_center_account_link_service_client.ts deleted file mode 100644 index b0a04656dff..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/merchant_center_account_link_service_client.ts +++ /dev/null @@ -1,1357 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, LocationsClient, LocationProtos} from 'google-gax'; - -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2alpha/merchant_center_account_link_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './merchant_center_account_link_service_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Merchant Center Link service to link a Branch to a Merchant Center Account. - * @class - * @memberof v2alpha - */ -export class MerchantCenterAccountLinkServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - merchantCenterAccountLinkServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of MerchantCenterAccountLinkServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new MerchantCenterAccountLinkServiceClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof MerchantCenterAccountLinkServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - this.locationsClient = new this._gaxModule.LocationsClient( - this._gaxGrpc, - opts - ); - - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - 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}' - ), - merchantCenterAccountLinkPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/merchantCenterAccountLinks/{merchant_center_account_link}' - ), - modelPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' - ), - 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. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',additional_bindings: [{get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/places/*/operations/*}',},{get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2alpha/{name=projects/*/locations/*/operations/*}',},{get: '/v2alpha/{name=projects/*/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2alpha/{name=projects/*/locations/*/catalogs/*}/operations',additional_bindings: [{get: '/v2alpha/{name=projects/*/locations/*}/operations',},{get: '/v2alpha/{name=projects/*}/operations',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const createMerchantCenterAccountLinkResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.MerchantCenterAccountLink') as gax.protobuf.Type; - const createMerchantCenterAccountLinkMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.CreateMerchantCenterAccountLinkMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - createMerchantCenterAccountLink: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createMerchantCenterAccountLinkResponse.decode.bind(createMerchantCenterAccountLinkResponse), - createMerchantCenterAccountLinkMetadata.decode.bind(createMerchantCenterAccountLinkMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2alpha.MerchantCenterAccountLinkService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.merchantCenterAccountLinkServiceStub) { - return this.merchantCenterAccountLinkServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2alpha.MerchantCenterAccountLinkService. - this.merchantCenterAccountLinkServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2alpha.MerchantCenterAccountLinkService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2alpha.MerchantCenterAccountLinkService, - 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 merchantCenterAccountLinkServiceStubMethods = - ['listMerchantCenterAccountLinks', 'createMerchantCenterAccountLink', 'deleteMerchantCenterAccountLink']; - for (const methodName of merchantCenterAccountLinkServiceStubMethods) { - const callPromise = this.merchantCenterAccountLinkServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.longrunning[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor, - this._opts.fallback - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.merchantCenterAccountLinkServiceStub; - } - - /** - * 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 -- - // ------------------- -/** - * Lists all - * {@link google.cloud.retail.v2alpha.MerchantCenterAccountLink|MerchantCenterAccountLink}s - * under the specified parent {@link google.cloud.retail.v2alpha.Catalog|Catalog}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent Catalog of the resource. - * It must match this format: - * projects/{PROJECT_NUMBER}/locations/global/catalogs/{CATALOG_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 {@link google.cloud.retail.v2alpha.ListMerchantCenterAccountLinksResponse | ListMerchantCenterAccountLinksResponse}. - * Please see 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/merchant_center_account_link_service.list_merchant_center_account_links.js - * region_tag:retail_v2alpha_generated_MerchantCenterAccountLinkService_ListMerchantCenterAccountLinks_async - */ - listMerchantCenterAccountLinks( - request?: protos.google.cloud.retail.v2alpha.IListMerchantCenterAccountLinksRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IListMerchantCenterAccountLinksResponse, - protos.google.cloud.retail.v2alpha.IListMerchantCenterAccountLinksRequest|undefined, {}|undefined - ]>; - listMerchantCenterAccountLinks( - request: protos.google.cloud.retail.v2alpha.IListMerchantCenterAccountLinksRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.IListMerchantCenterAccountLinksResponse, - protos.google.cloud.retail.v2alpha.IListMerchantCenterAccountLinksRequest|null|undefined, - {}|null|undefined>): void; - listMerchantCenterAccountLinks( - request: protos.google.cloud.retail.v2alpha.IListMerchantCenterAccountLinksRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.IListMerchantCenterAccountLinksResponse, - protos.google.cloud.retail.v2alpha.IListMerchantCenterAccountLinksRequest|null|undefined, - {}|null|undefined>): void; - listMerchantCenterAccountLinks( - request?: protos.google.cloud.retail.v2alpha.IListMerchantCenterAccountLinksRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.IListMerchantCenterAccountLinksResponse, - protos.google.cloud.retail.v2alpha.IListMerchantCenterAccountLinksRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.IListMerchantCenterAccountLinksResponse, - protos.google.cloud.retail.v2alpha.IListMerchantCenterAccountLinksRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.IListMerchantCenterAccountLinksResponse, - protos.google.cloud.retail.v2alpha.IListMerchantCenterAccountLinksRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listMerchantCenterAccountLinks(request, options, callback); - } -/** - * Deletes a - * {@link google.cloud.retail.v2alpha.MerchantCenterAccountLink|MerchantCenterAccountLink}. - * If the - * {@link google.cloud.retail.v2alpha.MerchantCenterAccountLink|MerchantCenterAccountLink} - * 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. Full resource name. Format: - * projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/merchantCenterAccountLinks/{merchant_center_account_link_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 {@link google.protobuf.Empty | 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/merchant_center_account_link_service.delete_merchant_center_account_link.js - * region_tag:retail_v2alpha_generated_MerchantCenterAccountLinkService_DeleteMerchantCenterAccountLink_async - */ - deleteMerchantCenterAccountLink( - request?: protos.google.cloud.retail.v2alpha.IDeleteMerchantCenterAccountLinkRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteMerchantCenterAccountLinkRequest|undefined, {}|undefined - ]>; - deleteMerchantCenterAccountLink( - request: protos.google.cloud.retail.v2alpha.IDeleteMerchantCenterAccountLinkRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteMerchantCenterAccountLinkRequest|null|undefined, - {}|null|undefined>): void; - deleteMerchantCenterAccountLink( - request: protos.google.cloud.retail.v2alpha.IDeleteMerchantCenterAccountLinkRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteMerchantCenterAccountLinkRequest|null|undefined, - {}|null|undefined>): void; - deleteMerchantCenterAccountLink( - request?: protos.google.cloud.retail.v2alpha.IDeleteMerchantCenterAccountLinkRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteMerchantCenterAccountLinkRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteMerchantCenterAccountLinkRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteMerchantCenterAccountLinkRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteMerchantCenterAccountLink(request, options, callback); - } - -/** - * Creates a - * {@link google.cloud.retail.v2alpha.MerchantCenterAccountLink|MerchantCenterAccountLink}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The branch resource where this MerchantCenterAccountLink will be - * created. Format: - * projects/{PROJECT_NUMBER}/locations/global/catalogs/{CATALOG_ID}} - * @param {google.cloud.retail.v2alpha.MerchantCenterAccountLink} request.merchantCenterAccountLink - * Required. The - * {@link google.cloud.retail.v2alpha.MerchantCenterAccountLink|MerchantCenterAccountLink} - * to create. - * - * If the caller does not have permission to create the - * {@link google.cloud.retail.v2alpha.MerchantCenterAccountLink|MerchantCenterAccountLink}, - * regardless of whether or not it exists, a PERMISSION_DENIED 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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [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/merchant_center_account_link_service.create_merchant_center_account_link.js - * region_tag:retail_v2alpha_generated_MerchantCenterAccountLinkService_CreateMerchantCenterAccountLink_async - */ - createMerchantCenterAccountLink( - request?: protos.google.cloud.retail.v2alpha.ICreateMerchantCenterAccountLinkRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createMerchantCenterAccountLink( - request: protos.google.cloud.retail.v2alpha.ICreateMerchantCenterAccountLinkRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createMerchantCenterAccountLink( - request: protos.google.cloud.retail.v2alpha.ICreateMerchantCenterAccountLinkRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createMerchantCenterAccountLink( - request?: protos.google.cloud.retail.v2alpha.ICreateMerchantCenterAccountLinkRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createMerchantCenterAccountLink(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createMerchantCenterAccountLink()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [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/merchant_center_account_link_service.create_merchant_center_account_link.js - * region_tag:retail_v2alpha_generated_MerchantCenterAccountLinkService_CreateMerchantCenterAccountLink_async - */ - async checkCreateMerchantCenterAccountLinkProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createMerchantCenterAccountLink, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Gets information about a location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Resource name for the location. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * ``` - * const [response] = await client.getLocation(request); - * ``` - */ - getLocation( - request: LocationProtos.google.cloud.location.IGetLocationRequest, - options?: - | gax.CallOptions - | Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - > - ): Promise { - return this.locationsClient.getLocation(request, options, callback); - } - -/** - * Lists information about the supported locations for this service. Returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The resource that owns the locations collection, if applicable. - * @param {string} request.filter - * The standard list filter. - * @param {number} request.pageSize - * The standard list page size. - * @param {string} request.pageToken - * The standard list page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example - * ``` - * const iterable = client.listLocationsAsync(request); - * for await (const response of iterable) { - * // process response - * } - * ``` - */ - listLocationsAsync( - request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions - ): AsyncIterable { - return this.locationsClient.listLocationsAsync(request, options); - } - -/** - * Gets the latest state of a long-running operation. Clients can use this - * method to poll the operation result at intervals as recommended by the API - * service. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error, ?Object)=} callback - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * const name = ''; - * const [response] = await client.getOperation({name}); - * // doThingsWith(response) - * ``` - */ - getOperation( - request: protos.google.longrunning.GetOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - > - ): Promise<[protos.google.longrunning.Operation]> { - return this.operationsClient.getOperation(request, options, callback); - } - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. - * - * For-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation collection. - * @param {string} request.filter - The standard list filter. - * @param {number=} request.pageSize - - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @returns {Object} - * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * for await (const response of client.listOperationsAsync(request)); - * // doThingsWith(response) - * ``` - */ - listOperationsAsync( - request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions - ): AsyncIterable { - return this.operationsClient.listOperationsAsync(request, options); - } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * {@link Operations.GetOperation} or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an {@link Operation.error} value with a {@link google.rpc.Status.code} of - * 1, corresponding to `Code.CANCELLED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be cancelled. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.cancelOperation({name: ''}); - * ``` - */ - cancelOperation( - request: protos.google.longrunning.CancelOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.CancelOperationRequest, - {} | undefined | null - >, - callback?: Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - > - ): Promise { - return this.operationsClient.cancelOperation(request, options, callback); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be deleted. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.deleteOperation({name: ''}); - * ``` - */ - deleteOperation( - request: protos.google.longrunning.DeleteOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - > - ): Promise { - return this.operationsClient.deleteOperation(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified 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 merchantCenterAccountLink resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} merchant_center_account_link - * @returns {string} Resource name string. - */ - merchantCenterAccountLinkPath(project:string,location:string,catalog:string,merchantCenterAccountLink:string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - merchant_center_account_link: merchantCenterAccountLink, - }); - } - - /** - * Parse the project from MerchantCenterAccountLink resource. - * - * @param {string} merchantCenterAccountLinkName - * A fully-qualified path representing MerchantCenterAccountLink resource. - * @returns {string} A string representing the project. - */ - matchProjectFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).project; - } - - /** - * Parse the location from MerchantCenterAccountLink resource. - * - * @param {string} merchantCenterAccountLinkName - * A fully-qualified path representing MerchantCenterAccountLink resource. - * @returns {string} A string representing the location. - */ - matchLocationFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).location; - } - - /** - * Parse the catalog from MerchantCenterAccountLink resource. - * - * @param {string} merchantCenterAccountLinkName - * A fully-qualified path representing MerchantCenterAccountLink resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).catalog; - } - - /** - * Parse the merchant_center_account_link from MerchantCenterAccountLink resource. - * - * @param {string} merchantCenterAccountLinkName - * A fully-qualified path representing MerchantCenterAccountLink resource. - * @returns {string} A string representing the merchant_center_account_link. - */ - matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).merchant_center_account_link; - } - - /** - * Return a fully-qualified model resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} model - * @returns {string} Resource name string. - */ - modelPath(project:string,location:string,catalog:string,model:string) { - return this.pathTemplates.modelPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - model: model, - }); - } - - /** - * Parse the project from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the project. - */ - matchProjectFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).project; - } - - /** - * Parse the location from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the location. - */ - matchLocationFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).location; - } - - /** - * Parse the catalog from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).catalog; - } - - /** - * Parse the model from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the model. - */ - matchModelFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).model; - } - - /** - * 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.merchantCenterAccountLinkServiceStub && !this._terminated) { - return this.merchantCenterAccountLinkServiceStub.then(stub => { - this._terminated = true; - stub.close(); - this.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/merchant_center_account_link_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/merchant_center_account_link_service_client_config.json deleted file mode 100644 index 218d843e54f..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/merchant_center_account_link_service_client_config.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2alpha.MerchantCenterAccountLinkService": { - "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": { - "ListMerchantCenterAccountLinks": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "CreateMerchantCenterAccountLink": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteMerchantCenterAccountLink": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/merchant_center_account_link_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/merchant_center_account_link_service_proto_list.json deleted file mode 100644 index b794e38509a..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/merchant_center_account_link_service_proto_list.json +++ /dev/null @@ -1,24 +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/merchant_center_account_link.proto", - "../../protos/google/cloud/retail/v2alpha/merchant_center_account_link_service.proto", - "../../protos/google/cloud/retail/v2alpha/model.proto", - "../../protos/google/cloud/retail/v2alpha/model_service.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/google-cloud-retail/v2alpha/src/v2alpha/model_service_client.ts b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/model_service_client.ts deleted file mode 100644 index 37550a76118..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/model_service_client.ts +++ /dev/null @@ -1,1877 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2alpha/model_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './model_service_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Service for performing CRUD operations on models. - * Recommendation models contain all the metadata necessary to generate a set of - * models for the `Predict()` API. A model is queried - * indirectly via a ServingConfig, which associates a model with a - * given Placement (e.g. Frequently Bought Together on Home Page). - * - * This service allows you to do the following: - * - * * Initiate training of a model. - * * Pause training of an existing model. - * * List all the available models along with their metadata. - * * Control their tuning schedule. - * @class - * @memberof v2alpha - */ -export class ModelServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - modelServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ModelServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new ModelServiceClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof ModelServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - this.locationsClient = new this._gaxModule.LocationsClient( - this._gaxGrpc, - opts - ); - - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - 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}' - ), - merchantCenterAccountLinkPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/merchantCenterAccountLinks/{merchant_center_account_link}' - ), - modelPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' - ), - 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 = { - listModels: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'models') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',additional_bindings: [{get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/places/*/operations/*}',},{get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2alpha/{name=projects/*/locations/*/operations/*}',},{get: '/v2alpha/{name=projects/*/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2alpha/{name=projects/*/locations/*/catalogs/*}/operations',additional_bindings: [{get: '/v2alpha/{name=projects/*/locations/*}/operations',},{get: '/v2alpha/{name=projects/*}/operations',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const createModelResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.Model') as gax.protobuf.Type; - const createModelMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.CreateModelMetadata') as gax.protobuf.Type; - const tuneModelResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.TuneModelResponse') as gax.protobuf.Type; - const tuneModelMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2alpha.TuneModelMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - createModel: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createModelResponse.decode.bind(createModelResponse), - createModelMetadata.decode.bind(createModelMetadata)), - tuneModel: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - tuneModelResponse.decode.bind(tuneModelResponse), - tuneModelMetadata.decode.bind(tuneModelMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2alpha.ModelService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.modelServiceStub) { - return this.modelServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2alpha.ModelService. - this.modelServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2alpha.ModelService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2alpha.ModelService, - 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 modelServiceStubMethods = - ['createModel', 'getModel', 'pauseModel', 'resumeModel', 'deleteModel', 'listModels', 'updateModel', 'tuneModel']; - for (const methodName of modelServiceStubMethods) { - const callPromise = this.modelServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - this.descriptors.longrunning[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor, - this._opts.fallback - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.modelServiceStub; - } - - /** - * 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 -- - // ------------------- -/** - * Gets a model. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the - * {@link google.cloud.retail.v2alpha.Model|Model} to get. Format: - * `projects/{project_number}/locations/{location_id}/catalogs/{catalog}/models/{model_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 {@link google.cloud.retail.v2alpha.Model | Model}. - * Please see 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/model_service.get_model.js - * region_tag:retail_v2alpha_generated_ModelService_GetModel_async - */ - getModel( - request?: protos.google.cloud.retail.v2alpha.IGetModelRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IModel, - protos.google.cloud.retail.v2alpha.IGetModelRequest|undefined, {}|undefined - ]>; - getModel( - request: protos.google.cloud.retail.v2alpha.IGetModelRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.IModel, - protos.google.cloud.retail.v2alpha.IGetModelRequest|null|undefined, - {}|null|undefined>): void; - getModel( - request: protos.google.cloud.retail.v2alpha.IGetModelRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.IModel, - protos.google.cloud.retail.v2alpha.IGetModelRequest|null|undefined, - {}|null|undefined>): void; - getModel( - request?: protos.google.cloud.retail.v2alpha.IGetModelRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.IModel, - protos.google.cloud.retail.v2alpha.IGetModelRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.IModel, - protos.google.cloud.retail.v2alpha.IGetModelRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.IModel, - protos.google.cloud.retail.v2alpha.IGetModelRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getModel(request, options, callback); - } -/** - * Pauses the training of an existing model. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the model to pause. - * Format: - * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_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 {@link google.cloud.retail.v2alpha.Model | Model}. - * Please see 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/model_service.pause_model.js - * region_tag:retail_v2alpha_generated_ModelService_PauseModel_async - */ - pauseModel( - request?: protos.google.cloud.retail.v2alpha.IPauseModelRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IModel, - protos.google.cloud.retail.v2alpha.IPauseModelRequest|undefined, {}|undefined - ]>; - pauseModel( - request: protos.google.cloud.retail.v2alpha.IPauseModelRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.IModel, - protos.google.cloud.retail.v2alpha.IPauseModelRequest|null|undefined, - {}|null|undefined>): void; - pauseModel( - request: protos.google.cloud.retail.v2alpha.IPauseModelRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.IModel, - protos.google.cloud.retail.v2alpha.IPauseModelRequest|null|undefined, - {}|null|undefined>): void; - pauseModel( - request?: protos.google.cloud.retail.v2alpha.IPauseModelRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.IModel, - protos.google.cloud.retail.v2alpha.IPauseModelRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.IModel, - protos.google.cloud.retail.v2alpha.IPauseModelRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.IModel, - protos.google.cloud.retail.v2alpha.IPauseModelRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.pauseModel(request, options, callback); - } -/** - * Resumes the training of an existing model. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the model to resume. - * Format: - * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_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 {@link google.cloud.retail.v2alpha.Model | Model}. - * Please see 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/model_service.resume_model.js - * region_tag:retail_v2alpha_generated_ModelService_ResumeModel_async - */ - resumeModel( - request?: protos.google.cloud.retail.v2alpha.IResumeModelRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IModel, - protos.google.cloud.retail.v2alpha.IResumeModelRequest|undefined, {}|undefined - ]>; - resumeModel( - request: protos.google.cloud.retail.v2alpha.IResumeModelRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.IModel, - protos.google.cloud.retail.v2alpha.IResumeModelRequest|null|undefined, - {}|null|undefined>): void; - resumeModel( - request: protos.google.cloud.retail.v2alpha.IResumeModelRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.IModel, - protos.google.cloud.retail.v2alpha.IResumeModelRequest|null|undefined, - {}|null|undefined>): void; - resumeModel( - request?: protos.google.cloud.retail.v2alpha.IResumeModelRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.IModel, - protos.google.cloud.retail.v2alpha.IResumeModelRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.IModel, - protos.google.cloud.retail.v2alpha.IResumeModelRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.IModel, - protos.google.cloud.retail.v2alpha.IResumeModelRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.resumeModel(request, options, callback); - } -/** - * Deletes an existing model. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the - * {@link google.cloud.retail.v2alpha.Model|Model} to delete. Format: - * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_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 {@link google.protobuf.Empty | 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/model_service.delete_model.js - * region_tag:retail_v2alpha_generated_ModelService_DeleteModel_async - */ - deleteModel( - request?: protos.google.cloud.retail.v2alpha.IDeleteModelRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteModelRequest|undefined, {}|undefined - ]>; - deleteModel( - request: protos.google.cloud.retail.v2alpha.IDeleteModelRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteModelRequest|null|undefined, - {}|null|undefined>): void; - deleteModel( - request: protos.google.cloud.retail.v2alpha.IDeleteModelRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteModelRequest|null|undefined, - {}|null|undefined>): void; - deleteModel( - request?: protos.google.cloud.retail.v2alpha.IDeleteModelRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteModelRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteModelRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2alpha.IDeleteModelRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteModel(request, options, callback); - } -/** - * Update of model metadata. Only fields that - * currently can be updated are: `filtering_option` and - * `periodic_tuning_state`. - * If other values are provided, this API method ignores them. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.retail.v2alpha.Model} request.model - * Required. The body of the updated - * {@link google.cloud.retail.v2alpha.Model|Model}. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Indicates which fields in the provided 'model' to - * update. If not set, by default updates all fields. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.retail.v2alpha.Model | Model}. - * Please see 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/model_service.update_model.js - * region_tag:retail_v2alpha_generated_ModelService_UpdateModel_async - */ - updateModel( - request?: protos.google.cloud.retail.v2alpha.IUpdateModelRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IModel, - protos.google.cloud.retail.v2alpha.IUpdateModelRequest|undefined, {}|undefined - ]>; - updateModel( - request: protos.google.cloud.retail.v2alpha.IUpdateModelRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2alpha.IModel, - protos.google.cloud.retail.v2alpha.IUpdateModelRequest|null|undefined, - {}|null|undefined>): void; - updateModel( - request: protos.google.cloud.retail.v2alpha.IUpdateModelRequest, - callback: Callback< - protos.google.cloud.retail.v2alpha.IModel, - protos.google.cloud.retail.v2alpha.IUpdateModelRequest|null|undefined, - {}|null|undefined>): void; - updateModel( - request?: protos.google.cloud.retail.v2alpha.IUpdateModelRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2alpha.IModel, - protos.google.cloud.retail.v2alpha.IUpdateModelRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2alpha.IModel, - protos.google.cloud.retail.v2alpha.IUpdateModelRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2alpha.IModel, - protos.google.cloud.retail.v2alpha.IUpdateModelRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'model.name': request.model!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateModel(request, options, callback); - } - -/** - * Creates a new model. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource under which to create the model. Format: - * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` - * @param {google.cloud.retail.v2alpha.Model} request.model - * Required. The payload of the {@link google.cloud.retail.v2alpha.Model|Model} to - * create. - * @param {boolean} [request.dryRun] - * Optional. Whether to run a dry run to validate the request (without - * actually creating the model). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [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/model_service.create_model.js - * region_tag:retail_v2alpha_generated_ModelService_CreateModel_async - */ - createModel( - request?: protos.google.cloud.retail.v2alpha.ICreateModelRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createModel( - request: protos.google.cloud.retail.v2alpha.ICreateModelRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createModel( - request: protos.google.cloud.retail.v2alpha.ICreateModelRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createModel( - request?: protos.google.cloud.retail.v2alpha.ICreateModelRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createModel(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createModel()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [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/model_service.create_model.js - * region_tag:retail_v2alpha_generated_ModelService_CreateModel_async - */ - async checkCreateModelProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createModel, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Tunes an existing model. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the model to tune. - * Format: - * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [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/model_service.tune_model.js - * region_tag:retail_v2alpha_generated_ModelService_TuneModel_async - */ - tuneModel( - request?: protos.google.cloud.retail.v2alpha.ITuneModelRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - tuneModel( - request: protos.google.cloud.retail.v2alpha.ITuneModelRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - tuneModel( - request: protos.google.cloud.retail.v2alpha.ITuneModelRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - tuneModel( - request?: protos.google.cloud.retail.v2alpha.ITuneModelRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.tuneModel(request, options, callback); - } -/** - * Check the status of the long running operation returned by `tuneModel()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [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/model_service.tune_model.js - * region_tag:retail_v2alpha_generated_ModelService_TuneModel_async - */ - async checkTuneModelProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.tuneModel, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists all the models linked to this event store. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent for which to list models. - * 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 `ListModels` - * 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 {@link google.cloud.retail.v2alpha.Model | Model}. - * 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 `listModelsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listModels( - request?: protos.google.cloud.retail.v2alpha.IListModelsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2alpha.IModel[], - protos.google.cloud.retail.v2alpha.IListModelsRequest|null, - protos.google.cloud.retail.v2alpha.IListModelsResponse - ]>; - listModels( - request: protos.google.cloud.retail.v2alpha.IListModelsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.retail.v2alpha.IListModelsRequest, - protos.google.cloud.retail.v2alpha.IListModelsResponse|null|undefined, - protos.google.cloud.retail.v2alpha.IModel>): void; - listModels( - request: protos.google.cloud.retail.v2alpha.IListModelsRequest, - callback: PaginationCallback< - protos.google.cloud.retail.v2alpha.IListModelsRequest, - protos.google.cloud.retail.v2alpha.IListModelsResponse|null|undefined, - protos.google.cloud.retail.v2alpha.IModel>): void; - listModels( - request?: protos.google.cloud.retail.v2alpha.IListModelsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.retail.v2alpha.IListModelsRequest, - protos.google.cloud.retail.v2alpha.IListModelsResponse|null|undefined, - protos.google.cloud.retail.v2alpha.IModel>, - callback?: PaginationCallback< - protos.google.cloud.retail.v2alpha.IListModelsRequest, - protos.google.cloud.retail.v2alpha.IListModelsResponse|null|undefined, - protos.google.cloud.retail.v2alpha.IModel>): - Promise<[ - protos.google.cloud.retail.v2alpha.IModel[], - protos.google.cloud.retail.v2alpha.IListModelsRequest|null, - protos.google.cloud.retail.v2alpha.IListModelsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listModels(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 for which to list models. - * 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 `ListModels` - * 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 {@link google.cloud.retail.v2alpha.Model | Model} 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 `listModelsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listModelsStream( - request?: protos.google.cloud.retail.v2alpha.IListModelsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listModels']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listModels.createStream( - this.innerApiCalls.listModels as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listModels`, 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 for which to list models. - * 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 `ListModels` - * 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 - * {@link google.cloud.retail.v2alpha.Model | Model}. 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/model_service.list_models.js - * region_tag:retail_v2alpha_generated_ModelService_ListModels_async - */ - listModelsAsync( - request?: protos.google.cloud.retail.v2alpha.IListModelsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listModels']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listModels.asyncIterate( - this.innerApiCalls['listModels'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } -/** - * Gets information about a location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Resource name for the location. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * ``` - * const [response] = await client.getLocation(request); - * ``` - */ - getLocation( - request: LocationProtos.google.cloud.location.IGetLocationRequest, - options?: - | gax.CallOptions - | Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - > - ): Promise { - return this.locationsClient.getLocation(request, options, callback); - } - -/** - * Lists information about the supported locations for this service. Returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The resource that owns the locations collection, if applicable. - * @param {string} request.filter - * The standard list filter. - * @param {number} request.pageSize - * The standard list page size. - * @param {string} request.pageToken - * The standard list page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example - * ``` - * const iterable = client.listLocationsAsync(request); - * for await (const response of iterable) { - * // process response - * } - * ``` - */ - listLocationsAsync( - request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions - ): AsyncIterable { - return this.locationsClient.listLocationsAsync(request, options); - } - -/** - * Gets the latest state of a long-running operation. Clients can use this - * method to poll the operation result at intervals as recommended by the API - * service. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error, ?Object)=} callback - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * const name = ''; - * const [response] = await client.getOperation({name}); - * // doThingsWith(response) - * ``` - */ - getOperation( - request: protos.google.longrunning.GetOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - > - ): Promise<[protos.google.longrunning.Operation]> { - return this.operationsClient.getOperation(request, options, callback); - } - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. - * - * For-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation collection. - * @param {string} request.filter - The standard list filter. - * @param {number=} request.pageSize - - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @returns {Object} - * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * for await (const response of client.listOperationsAsync(request)); - * // doThingsWith(response) - * ``` - */ - listOperationsAsync( - request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions - ): AsyncIterable { - return this.operationsClient.listOperationsAsync(request, options); - } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * {@link Operations.GetOperation} or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an {@link Operation.error} value with a {@link google.rpc.Status.code} of - * 1, corresponding to `Code.CANCELLED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be cancelled. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.cancelOperation({name: ''}); - * ``` - */ - cancelOperation( - request: protos.google.longrunning.CancelOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.CancelOperationRequest, - {} | undefined | null - >, - callback?: Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - > - ): Promise { - return this.operationsClient.cancelOperation(request, options, callback); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be deleted. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.deleteOperation({name: ''}); - * ``` - */ - deleteOperation( - request: protos.google.longrunning.DeleteOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - > - ): Promise { - return this.operationsClient.deleteOperation(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified 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 merchantCenterAccountLink resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} merchant_center_account_link - * @returns {string} Resource name string. - */ - merchantCenterAccountLinkPath(project:string,location:string,catalog:string,merchantCenterAccountLink:string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - merchant_center_account_link: merchantCenterAccountLink, - }); - } - - /** - * Parse the project from MerchantCenterAccountLink resource. - * - * @param {string} merchantCenterAccountLinkName - * A fully-qualified path representing MerchantCenterAccountLink resource. - * @returns {string} A string representing the project. - */ - matchProjectFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).project; - } - - /** - * Parse the location from MerchantCenterAccountLink resource. - * - * @param {string} merchantCenterAccountLinkName - * A fully-qualified path representing MerchantCenterAccountLink resource. - * @returns {string} A string representing the location. - */ - matchLocationFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).location; - } - - /** - * Parse the catalog from MerchantCenterAccountLink resource. - * - * @param {string} merchantCenterAccountLinkName - * A fully-qualified path representing MerchantCenterAccountLink resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).catalog; - } - - /** - * Parse the merchant_center_account_link from MerchantCenterAccountLink resource. - * - * @param {string} merchantCenterAccountLinkName - * A fully-qualified path representing MerchantCenterAccountLink resource. - * @returns {string} A string representing the merchant_center_account_link. - */ - matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).merchant_center_account_link; - } - - /** - * Return a fully-qualified model resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} model - * @returns {string} Resource name string. - */ - modelPath(project:string,location:string,catalog:string,model:string) { - return this.pathTemplates.modelPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - model: model, - }); - } - - /** - * Parse the project from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the project. - */ - matchProjectFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).project; - } - - /** - * Parse the location from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the location. - */ - matchLocationFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).location; - } - - /** - * Parse the catalog from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).catalog; - } - - /** - * Parse the model from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the model. - */ - matchModelFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).model; - } - - /** - * 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.modelServiceStub && !this._terminated) { - return this.modelServiceStub.then(stub => { - this._terminated = true; - stub.close(); - this.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/model_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/model_service_client_config.json deleted file mode 100644 index 7734305bc78..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/model_service_client_config.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2alpha.ModelService": { - "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": { - "CreateModel": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "GetModel": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "PauseModel": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ResumeModel": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "DeleteModel": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ListModels": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "UpdateModel": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "TuneModel": { - "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/model_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/model_service_proto_list.json deleted file mode 100644 index b794e38509a..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/model_service_proto_list.json +++ /dev/null @@ -1,24 +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/merchant_center_account_link.proto", - "../../protos/google/cloud/retail/v2alpha/merchant_center_account_link_service.proto", - "../../protos/google/cloud/retail/v2alpha/model.proto", - "../../protos/google/cloud/retail/v2alpha/model_service.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/google-cloud-retail/v2alpha/src/v2alpha/prediction_service_client.ts b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/prediction_service_client.ts deleted file mode 100644 index 21164b7a844..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/prediction_service_client.ts +++ /dev/null @@ -1,1291 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LocationsClient, LocationProtos} 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}; - locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - 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/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new PredictionServiceClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof 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); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - this.locationsClient = new this._gaxModule.LocationsClient( - this._gaxGrpc, - opts - ); - - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - 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}' - ), - merchantCenterAccountLinkPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/merchantCenterAccountLinks/{merchant_center_account_link}' - ), - modelPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' - ), - 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. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',additional_bindings: [{get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/places/*/operations/*}',},{get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2alpha/{name=projects/*/locations/*/operations/*}',},{get: '/v2alpha/{name=projects/*/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2alpha/{name=projects/*/locations/*/catalogs/*}/operations',additional_bindings: [{get: '/v2alpha/{name=projects/*/locations/*}/operations',},{get: '/v2alpha/{name=projects/*}/operations',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - - this.descriptors.longrunning = { - }; - - // 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 = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.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._opts.fallback - ); - - 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: - * `{placement=projects/* /locations/global/catalogs/default_catalog/servingConfigs/*}` - * or - * `{placement=projects/* /locations/global/catalogs/default_catalog/placements/*}`. - * We recommend using the `servingConfigs` resource. `placements` is a legacy - * resource. - * The ID of the Recommendations AI serving config or placement. - * Before you can request predictions from your model, you must create at - * least one serving config or placement for it. For more information, see - * [Manage serving configs] - * (https://cloud.google.com/retail/docs/manage-configs). - * - * The full list of available serving configs can be seen at - * https://console.cloud.google.com/ai/retail/catalogs/default_catalog/configs - * @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. - * - * Don't set - * {@link google.cloud.retail.v2alpha.UserEvent.visitor_id|UserEvent.visitor_id} or - * {@link google.cloud.retail.v2alpha.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.v2alpha.UserEvent.visitor_id|UserEvent.visitor_id} to - * a random unique ID and leave - * {@link google.cloud.retail.v2alpha.UserInfo.user_id|UserInfo.user_id} unset. - * @param {number} request.pageSize - * Maximum number of results to return. 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 - * This field is not used; leave it unset. - * @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 *no* - * results. If instead you want empty result sets to return generic - * (unfiltered) popular products, set `strictFiltering` to False in - * `PredictRequest.params`. Note that the API will never return items with - * storageStatus of "EXPIRED" or "DELETED" regardless of filter choices. - * - * If `filterSyntaxV2` is set to true under the `params` field, then - * attribute-based expressions are expected instead of the above described - * tag-based syntax. Examples: - * - * * (colors: ANY("Red", "Blue")) AND NOT (categories: ANY("Phones")) - * * (availability: ANY("IN_STOCK")) AND - * (colors: ANY("Red") OR categories: ANY("Phones")) - * - * For more information, see - * [Filter recommendations](https://cloud.google.com/retail/docs/filter-recs). - * @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 a 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. - * * `filterSyntaxV2`: Boolean. False by default. If set to true, the `filter` - * field is interpreteted according to the new, attribute-based syntax. - * @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 {@link google.cloud.retail.v2alpha.PredictResponse | 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'placement': request.placement ?? '', - }); - this.initialize(); - return this.innerApiCalls.predict(request, options, callback); - } - -/** - * Gets information about a location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Resource name for the location. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * ``` - * const [response] = await client.getLocation(request); - * ``` - */ - getLocation( - request: LocationProtos.google.cloud.location.IGetLocationRequest, - options?: - | gax.CallOptions - | Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - > - ): Promise { - return this.locationsClient.getLocation(request, options, callback); - } - -/** - * Lists information about the supported locations for this service. Returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The resource that owns the locations collection, if applicable. - * @param {string} request.filter - * The standard list filter. - * @param {number} request.pageSize - * The standard list page size. - * @param {string} request.pageToken - * The standard list page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example - * ``` - * const iterable = client.listLocationsAsync(request); - * for await (const response of iterable) { - * // process response - * } - * ``` - */ - listLocationsAsync( - request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions - ): AsyncIterable { - return this.locationsClient.listLocationsAsync(request, options); - } - -/** - * Gets the latest state of a long-running operation. Clients can use this - * method to poll the operation result at intervals as recommended by the API - * service. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error, ?Object)=} callback - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * const name = ''; - * const [response] = await client.getOperation({name}); - * // doThingsWith(response) - * ``` - */ - getOperation( - request: protos.google.longrunning.GetOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - > - ): Promise<[protos.google.longrunning.Operation]> { - return this.operationsClient.getOperation(request, options, callback); - } - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. - * - * For-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation collection. - * @param {string} request.filter - The standard list filter. - * @param {number=} request.pageSize - - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @returns {Object} - * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * for await (const response of client.listOperationsAsync(request)); - * // doThingsWith(response) - * ``` - */ - listOperationsAsync( - request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions - ): AsyncIterable { - return this.operationsClient.listOperationsAsync(request, options); - } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * {@link Operations.GetOperation} or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an {@link Operation.error} value with a {@link google.rpc.Status.code} of - * 1, corresponding to `Code.CANCELLED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be cancelled. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.cancelOperation({name: ''}); - * ``` - */ - cancelOperation( - request: protos.google.longrunning.CancelOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.CancelOperationRequest, - {} | undefined | null - >, - callback?: Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - > - ): Promise { - return this.operationsClient.cancelOperation(request, options, callback); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be deleted. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.deleteOperation({name: ''}); - * ``` - */ - deleteOperation( - request: protos.google.longrunning.DeleteOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - > - ): Promise { - return this.operationsClient.deleteOperation(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified 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 merchantCenterAccountLink resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} merchant_center_account_link - * @returns {string} Resource name string. - */ - merchantCenterAccountLinkPath(project:string,location:string,catalog:string,merchantCenterAccountLink:string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - merchant_center_account_link: merchantCenterAccountLink, - }); - } - - /** - * Parse the project from MerchantCenterAccountLink resource. - * - * @param {string} merchantCenterAccountLinkName - * A fully-qualified path representing MerchantCenterAccountLink resource. - * @returns {string} A string representing the project. - */ - matchProjectFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).project; - } - - /** - * Parse the location from MerchantCenterAccountLink resource. - * - * @param {string} merchantCenterAccountLinkName - * A fully-qualified path representing MerchantCenterAccountLink resource. - * @returns {string} A string representing the location. - */ - matchLocationFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).location; - } - - /** - * Parse the catalog from MerchantCenterAccountLink resource. - * - * @param {string} merchantCenterAccountLinkName - * A fully-qualified path representing MerchantCenterAccountLink resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).catalog; - } - - /** - * Parse the merchant_center_account_link from MerchantCenterAccountLink resource. - * - * @param {string} merchantCenterAccountLinkName - * A fully-qualified path representing MerchantCenterAccountLink resource. - * @returns {string} A string representing the merchant_center_account_link. - */ - matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).merchant_center_account_link; - } - - /** - * Return a fully-qualified model resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} model - * @returns {string} Resource name string. - */ - modelPath(project:string,location:string,catalog:string,model:string) { - return this.pathTemplates.modelPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - model: model, - }); - } - - /** - * Parse the project from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the project. - */ - matchProjectFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).project; - } - - /** - * Parse the location from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the location. - */ - matchLocationFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).location; - } - - /** - * Parse the catalog from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).catalog; - } - - /** - * Parse the model from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the model. - */ - matchModelFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).model; - } - - /** - * 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(); - this.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/prediction_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/prediction_service_client_config.json deleted file mode 100644 index ed48fe50101..00000000000 --- a/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2alpha/src/v2alpha/prediction_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/prediction_service_proto_list.json deleted file mode 100644 index b794e38509a..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/prediction_service_proto_list.json +++ /dev/null @@ -1,24 +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/merchant_center_account_link.proto", - "../../protos/google/cloud/retail/v2alpha/merchant_center_account_link_service.proto", - "../../protos/google/cloud/retail/v2alpha/model.proto", - "../../protos/google/cloud/retail/v2alpha/model_service.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/google-cloud-retail/v2alpha/src/v2alpha/product_service_client.ts b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/product_service_client.ts deleted file mode 100644 index 255919269a0..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/product_service_client.ts +++ /dev/null @@ -1,3133 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/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'; -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}; - locationsClient: LocationsClient; - 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/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new ProductServiceClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof 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); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - this.locationsClient = new this._gaxModule.LocationsClient( - this._gaxGrpc, - opts - ); - - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - 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}' - ), - merchantCenterAccountLinkPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/merchantCenterAccountLinks/{merchant_center_account_link}' - ), - modelPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' - ), - 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. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',additional_bindings: [{get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/places/*/operations/*}',},{get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2alpha/{name=projects/*/locations/*/operations/*}',},{get: '/v2alpha/{name=projects/*/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2alpha/{name=projects/*/locations/*/catalogs/*}/operations',additional_bindings: [{get: '/v2alpha/{name=projects/*/locations/*}/operations',},{get: '/v2alpha/{name=projects/*}/operations',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).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 = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.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._opts.fallback - ); - - 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 {@link google.cloud.retail.v2alpha.Product | 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' - ] = this._gaxModule.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 {@link google.cloud.retail.v2alpha.Product | 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' - ] = this._gaxModule.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. - * - * 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.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 {@link google.cloud.retail.v2alpha.Product | 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' - ] = this._gaxModule.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 {boolean} request.force - * This value only applies to the case when the target product is of type - * PRIMARY. - * When deleting a product of VARIANT/COLLECTION type, this value - * will be ignored. - * When set to true, the subsequent variant products will be - * deleted. - * When set to false, if the primary product has active variant products, an - * error will be 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 {@link google.protobuf.Empty | 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' - ] = this._gaxModule.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|ProductService.GetProduct} - * or - * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.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' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.purgeProducts(request, options, callback); - } -/** - * Check the status of the long running operation returned by `purgeProducts()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2alpha/product_service.purge_products.js - * region_tag:retail_v2alpha_generated_ProductService_PurgeProducts_async - */ - async checkPurgeProductsProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.purgeProducts, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Bulk import of multiple {@link google.cloud.retail.v2alpha.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.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, all fields are updated. - * @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 - * Full Pub/Sub topic name for receiving notification. If this field is set, - * when the import is finished, a notification is sent to - * specified Pub/Sub topic. The message data is 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.v2alpha.ImportProductsRequest.parent|ImportProductsRequest.parent}. - * Make sure that `service-@gcp-sa-retail.iam.gserviceaccount.com` has the - * `pubsub.topics.publish` IAM permission on the topic. - * @param {boolean} request.skipDefaultBranchProtection - * If true, this performs the FULL import even if it would delete a large - * proportion of the products in the default branch, which could potentially - * cause outages if you have live predict/search traffic. - * - * 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' - ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.importProducts, this._gaxModule.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 is 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|ProductService.GetProduct} - * or - * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts}. - * - * When inventory is updated with - * {@link google.cloud.retail.v2alpha.ProductService.CreateProduct|ProductService.CreateProduct} - * and - * {@link google.cloud.retail.v2alpha.ProductService.UpdateProduct|ProductService.UpdateProduct}, - * the specified inventory field value(s) overwrite any existing value(s) - * while ignoring the last update time for this field. Furthermore, the last - * update times for the specified inventory fields are overwritten by the - * times of the - * {@link google.cloud.retail.v2alpha.ProductService.CreateProduct|ProductService.CreateProduct} - * or - * {@link google.cloud.retail.v2alpha.ProductService.UpdateProduct|ProductService.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 is used. - * - * If no inventory fields are set in - * {@link google.cloud.retail.v2alpha.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask}, - * then any existing inventory information is preserved. - * - * Pre-existing inventory information can only be updated with - * {@link google.cloud.retail.v2alpha.ProductService.SetInventory|ProductService.SetInventory}, - * {@link google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlaces|ProductService.AddFulfillmentPlaces}, - * and - * {@link google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces|ProductService.RemoveFulfillmentPlaces}. - * - * The returned {@link google.longrunning.Operation|Operation}s is obsolete after - * one day, and the {@link google.longrunning.Operations.GetOperation|GetOperation} - * API returns `NOT_FOUND` afterwards. - * - * If conflicting updates are issued, the - * {@link google.longrunning.Operation|Operation}s associated with the stale - * updates are not marked as {@link google.longrunning.Operation.done|done} until - * they are obsolete. - * - * @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 google.cloud.retail.v2alpha.Product.name|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 google.cloud.retail.v2alpha.Product.fulfillment_info|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 google.cloud.retail.v2alpha.Product.fulfillment_info|SetInventoryRequest.inventory.fulfillment_info} - * * Checks that only the desired fulfillment info types have empty - * {@link google.cloud.retail.v2alpha.FulfillmentInfo.place_ids|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 google.cloud.retail.v2alpha.ProductService.UpdateProduct|ProductService.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' - ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.setInventory, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * It is recommended to use the - * {@link google.cloud.retail.v2alpha.ProductService.AddLocalInventories|ProductService.AddLocalInventories} - * method instead of - * {@link google.cloud.retail.v2alpha.ProductService.AddFulfillmentPlaces|ProductService.AddFulfillmentPlaces}. - * {@link google.cloud.retail.v2alpha.ProductService.AddLocalInventories|ProductService.AddLocalInventories} - * achieves the same results but provides more fine-grained control over - * ingesting local inventory data. - * - * 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|ProductService.GetProduct} - * or - * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts}. - * - * The returned {@link google.longrunning.Operation|Operation}s will be obsolete - * after 1 day, and {@link google.longrunning.Operations.GetOperation|GetOperation} - * API will return NOT_FOUND afterwards. - * - * If conflicting updates are issued, the - * {@link google.longrunning.Operation|Operation}s associated with the stale - * updates will not be marked as {@link google.longrunning.Operation.done|done} - * until being obsolete. - * - * @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 google.cloud.retail.v2alpha.FulfillmentInfo.type|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' - ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.addFulfillmentPlaces, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * It is recommended to use the - * {@link google.cloud.retail.v2alpha.ProductService.RemoveLocalInventories|ProductService.RemoveLocalInventories} - * method instead of - * {@link google.cloud.retail.v2alpha.ProductService.RemoveFulfillmentPlaces|ProductService.RemoveFulfillmentPlaces}. - * {@link google.cloud.retail.v2alpha.ProductService.RemoveLocalInventories|ProductService.RemoveLocalInventories} - * achieves the same results but provides more fine-grained control over - * ingesting local inventory data. - * - * 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|ProductService.GetProduct} - * or - * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts}. - * - * The returned {@link google.longrunning.Operation|Operation}s will be obsolete - * after 1 day, and {@link google.longrunning.Operations.GetOperation|GetOperation} - * API will return NOT_FOUND afterwards. - * - * If conflicting updates are issued, the - * {@link google.longrunning.Operation|Operation}s associated with the stale - * updates will not be marked as {@link google.longrunning.Operation.done|done} - * until being obsolete. - * - * @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 google.cloud.retail.v2alpha.FulfillmentInfo.type|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' - ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.removeFulfillmentPlaces, this._gaxModule.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|ProductService.GetProduct} - * or - * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts}. - * - * Local inventory information can only be modified using this method. - * {@link google.cloud.retail.v2alpha.ProductService.CreateProduct|ProductService.CreateProduct} - * and - * {@link google.cloud.retail.v2alpha.ProductService.UpdateProduct|ProductService.UpdateProduct} - * has no effect on local inventories. - * - * The returned {@link google.longrunning.Operation|Operation}s will be obsolete - * after 1 day, and {@link google.longrunning.Operations.GetOperation|GetOperation} - * API will return NOT_FOUND afterwards. - * - * If conflicting updates are issued, the - * {@link google.longrunning.Operation|Operation}s associated with the stale - * updates will not be marked as {@link google.longrunning.Operation.done|done} - * until being obsolete. - * - * @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' - ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.addLocalInventories, this._gaxModule.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|ProductService.GetProduct} - * or - * {@link google.cloud.retail.v2alpha.ProductService.ListProducts|ProductService.ListProducts}. - * - * Local inventory information can only be removed using this method. - * {@link google.cloud.retail.v2alpha.ProductService.CreateProduct|ProductService.CreateProduct} - * and - * {@link google.cloud.retail.v2alpha.ProductService.UpdateProduct|ProductService.UpdateProduct} - * has no effect on local inventories. - * - * The returned {@link google.longrunning.Operation|Operation}s will be obsolete - * after 1 day, and {@link google.longrunning.Operations.GetOperation|GetOperation} - * API will return NOT_FOUND afterwards. - * - * If conflicting updates are issued, the - * {@link google.longrunning.Operation|Operation}s associated with the stale - * updates will not be marked as {@link google.longrunning.Operation.done|done} - * until being obsolete. - * - * @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' - ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.removeLocalInventories, this._gaxModule.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 {@link google.cloud.retail.v2alpha.Product | 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listProducts(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The 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 {@link google.cloud.retail.v2alpha.Product | 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listProducts']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProducts.createStream( - this.innerApiCalls.listProducts as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProducts`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The 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 - * {@link google.cloud.retail.v2alpha.Product | 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listProducts']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProducts.asyncIterate( - this.innerApiCalls['listProducts'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } -/** - * Gets information about a location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Resource name for the location. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * ``` - * const [response] = await client.getLocation(request); - * ``` - */ - getLocation( - request: LocationProtos.google.cloud.location.IGetLocationRequest, - options?: - | gax.CallOptions - | Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - > - ): Promise { - return this.locationsClient.getLocation(request, options, callback); - } - -/** - * Lists information about the supported locations for this service. Returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The resource that owns the locations collection, if applicable. - * @param {string} request.filter - * The standard list filter. - * @param {number} request.pageSize - * The standard list page size. - * @param {string} request.pageToken - * The standard list page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example - * ``` - * const iterable = client.listLocationsAsync(request); - * for await (const response of iterable) { - * // process response - * } - * ``` - */ - listLocationsAsync( - request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions - ): AsyncIterable { - return this.locationsClient.listLocationsAsync(request, options); - } - -/** - * Gets the latest state of a long-running operation. Clients can use this - * method to poll the operation result at intervals as recommended by the API - * service. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error, ?Object)=} callback - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * const name = ''; - * const [response] = await client.getOperation({name}); - * // doThingsWith(response) - * ``` - */ - getOperation( - request: protos.google.longrunning.GetOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - > - ): Promise<[protos.google.longrunning.Operation]> { - return this.operationsClient.getOperation(request, options, callback); - } - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. - * - * For-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation collection. - * @param {string} request.filter - The standard list filter. - * @param {number=} request.pageSize - - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @returns {Object} - * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * for await (const response of client.listOperationsAsync(request)); - * // doThingsWith(response) - * ``` - */ - listOperationsAsync( - request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions - ): AsyncIterable { - return this.operationsClient.listOperationsAsync(request, options); - } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * {@link Operations.GetOperation} or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an {@link Operation.error} value with a {@link google.rpc.Status.code} of - * 1, corresponding to `Code.CANCELLED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be cancelled. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.cancelOperation({name: ''}); - * ``` - */ - cancelOperation( - request: protos.google.longrunning.CancelOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.CancelOperationRequest, - {} | undefined | null - >, - callback?: Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - > - ): Promise { - return this.operationsClient.cancelOperation(request, options, callback); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be deleted. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.deleteOperation({name: ''}); - * ``` - */ - deleteOperation( - request: protos.google.longrunning.DeleteOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - > - ): Promise { - return this.operationsClient.deleteOperation(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified 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 merchantCenterAccountLink resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} merchant_center_account_link - * @returns {string} Resource name string. - */ - merchantCenterAccountLinkPath(project:string,location:string,catalog:string,merchantCenterAccountLink:string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - merchant_center_account_link: merchantCenterAccountLink, - }); - } - - /** - * Parse the project from MerchantCenterAccountLink resource. - * - * @param {string} merchantCenterAccountLinkName - * A fully-qualified path representing MerchantCenterAccountLink resource. - * @returns {string} A string representing the project. - */ - matchProjectFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).project; - } - - /** - * Parse the location from MerchantCenterAccountLink resource. - * - * @param {string} merchantCenterAccountLinkName - * A fully-qualified path representing MerchantCenterAccountLink resource. - * @returns {string} A string representing the location. - */ - matchLocationFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).location; - } - - /** - * Parse the catalog from MerchantCenterAccountLink resource. - * - * @param {string} merchantCenterAccountLinkName - * A fully-qualified path representing MerchantCenterAccountLink resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).catalog; - } - - /** - * Parse the merchant_center_account_link from MerchantCenterAccountLink resource. - * - * @param {string} merchantCenterAccountLinkName - * A fully-qualified path representing MerchantCenterAccountLink resource. - * @returns {string} A string representing the merchant_center_account_link. - */ - matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).merchant_center_account_link; - } - - /** - * Return a fully-qualified model resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} model - * @returns {string} Resource name string. - */ - modelPath(project:string,location:string,catalog:string,model:string) { - return this.pathTemplates.modelPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - model: model, - }); - } - - /** - * Parse the project from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the project. - */ - matchProjectFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).project; - } - - /** - * Parse the location from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the location. - */ - matchLocationFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).location; - } - - /** - * Parse the catalog from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).catalog; - } - - /** - * Parse the model from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the model. - */ - matchModelFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).model; - } - - /** - * 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.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/product_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/product_service_client_config.json deleted file mode 100644 index 416ef1ec1c3..00000000000 --- a/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2alpha/src/v2alpha/product_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/product_service_proto_list.json deleted file mode 100644 index b794e38509a..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/product_service_proto_list.json +++ /dev/null @@ -1,24 +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/merchant_center_account_link.proto", - "../../protos/google/cloud/retail/v2alpha/merchant_center_account_link_service.proto", - "../../protos/google/cloud/retail/v2alpha/model.proto", - "../../protos/google/cloud/retail/v2alpha/model_service.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/google-cloud-retail/v2alpha/src/v2alpha/search_service_client.ts b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/search_service_client.ts deleted file mode 100644 index bcc89dff5b7..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/search_service_client.ts +++ /dev/null @@ -1,2165 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/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. - * 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}; - locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - 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/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new SearchServiceClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof 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); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - this.locationsClient = new this._gaxModule.LocationsClient( - this._gaxGrpc, - opts - ); - - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - 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}' - ), - experimentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/experiments/{experiment}' - ), - merchantCenterAccountLinkPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/merchantCenterAccountLinks/{merchant_center_account_link}' - ), - modelPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' - ), - 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') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',additional_bindings: [{get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/places/*/operations/*}',},{get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2alpha/{name=projects/*/locations/*/operations/*}',},{get: '/v2alpha/{name=projects/*/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2alpha/{name=projects/*/locations/*/catalogs/*}/operations',additional_bindings: [{get: '/v2alpha/{name=projects/*/locations/*}/operations',},{get: '/v2alpha/{name=projects/*}/operations',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - - this.descriptors.longrunning = { - }; - - // 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 = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.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._opts.fallback - ); - - 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. - * 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 Retail Search serving config, such as - * `projects/* /locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` - * or the name of the legacy placement resource, such as - * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. - * This field is used to identify the serving config 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.v2alpha.SearchRequest.filter|filter} and - * {@link google.cloud.retail.v2alpha.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.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 200 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 - * {@link google.cloud.retail.v2alpha.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.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 google.cloud.retail.v2alpha.LocalInventory.attributes|Product.local_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. Must be set 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, 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. - * - * Notice that if both - * {@link google.cloud.retail.v2alpha.ServingConfig.personalization_spec|ServingConfig.personalization_spec} - * and - * {@link google.cloud.retail.v2alpha.SearchRequest.personalization_spec|SearchRequest.personalization_spec} - * are set. - * {@link google.cloud.retail.v2alpha.SearchRequest.personalization_spec|SearchRequest.personalization_spec} - * will override - * {@link google.cloud.retail.v2alpha.ServingConfig.personalization_spec|ServingConfig.personalization_spec}. - * @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.v2alpha.SearchRequest.SpellCorrectionSpec} request.spellCorrectionSpec - * The spell correction specification that specifies the mode under - * which spell correction will take effect. - * @param {string} request.entity - * The entity for customers that may run multiple different entities, domains, - * sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, - * `google.com`, `youtube.com`, etc. - * If this is set, it should be exactly matched with - * {@link google.cloud.retail.v2alpha.UserEvent.entity|UserEvent.entity} to get - * search results boosted by entity. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 {@link google.cloud.retail.v2alpha.SearchResponse.SearchResult | 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' - ] = this._gaxModule.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 Retail Search serving config, such as - * `projects/* /locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` - * or the name of the legacy placement resource, such as - * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. - * This field is used to identify the serving config 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.v2alpha.SearchRequest.filter|filter} and - * {@link google.cloud.retail.v2alpha.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.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 200 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 - * {@link google.cloud.retail.v2alpha.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.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 google.cloud.retail.v2alpha.LocalInventory.attributes|Product.local_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. Must be set 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, 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. - * - * Notice that if both - * {@link google.cloud.retail.v2alpha.ServingConfig.personalization_spec|ServingConfig.personalization_spec} - * and - * {@link google.cloud.retail.v2alpha.SearchRequest.personalization_spec|SearchRequest.personalization_spec} - * are set. - * {@link google.cloud.retail.v2alpha.SearchRequest.personalization_spec|SearchRequest.personalization_spec} - * will override - * {@link google.cloud.retail.v2alpha.ServingConfig.personalization_spec|ServingConfig.personalization_spec}. - * @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.v2alpha.SearchRequest.SpellCorrectionSpec} request.spellCorrectionSpec - * The spell correction specification that specifies the mode under - * which spell correction will take effect. - * @param {string} request.entity - * The entity for customers that may run multiple different entities, domains, - * sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, - * `google.com`, `youtube.com`, etc. - * If this is set, it should be exactly matched with - * {@link google.cloud.retail.v2alpha.UserEvent.entity|UserEvent.entity} to get - * search results boosted by entity. - * @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 {@link google.cloud.retail.v2alpha.SearchResponse.SearchResult | 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' - ] = this._gaxModule.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 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 Retail Search serving config, such as - * `projects/* /locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` - * or the name of the legacy placement resource, such as - * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. - * This field is used to identify the serving config 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.v2alpha.SearchRequest.filter|filter} and - * {@link google.cloud.retail.v2alpha.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.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 200 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 - * {@link google.cloud.retail.v2alpha.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.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 google.cloud.retail.v2alpha.LocalInventory.attributes|Product.local_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. Must be set 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, 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. - * - * Notice that if both - * {@link google.cloud.retail.v2alpha.ServingConfig.personalization_spec|ServingConfig.personalization_spec} - * and - * {@link google.cloud.retail.v2alpha.SearchRequest.personalization_spec|SearchRequest.personalization_spec} - * are set. - * {@link google.cloud.retail.v2alpha.SearchRequest.personalization_spec|SearchRequest.personalization_spec} - * will override - * {@link google.cloud.retail.v2alpha.ServingConfig.personalization_spec|ServingConfig.personalization_spec}. - * @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.v2alpha.SearchRequest.SpellCorrectionSpec} request.spellCorrectionSpec - * The spell correction specification that specifies the mode under - * which spell correction will take effect. - * @param {string} request.entity - * The entity for customers that may run multiple different entities, domains, - * sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, - * `google.com`, `youtube.com`, etc. - * If this is set, it should be exactly matched with - * {@link google.cloud.retail.v2alpha.UserEvent.entity|UserEvent.entity} to get - * search results boosted by entity. - * @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 - * {@link google.cloud.retail.v2alpha.SearchResponse.SearchResult | 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' - ] = this._gaxModule.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 {}, - callSettings - ) as AsyncIterable; - } -/** - * Gets information about a location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Resource name for the location. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * ``` - * const [response] = await client.getLocation(request); - * ``` - */ - getLocation( - request: LocationProtos.google.cloud.location.IGetLocationRequest, - options?: - | gax.CallOptions - | Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - > - ): Promise { - return this.locationsClient.getLocation(request, options, callback); - } - -/** - * Lists information about the supported locations for this service. Returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The resource that owns the locations collection, if applicable. - * @param {string} request.filter - * The standard list filter. - * @param {number} request.pageSize - * The standard list page size. - * @param {string} request.pageToken - * The standard list page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example - * ``` - * const iterable = client.listLocationsAsync(request); - * for await (const response of iterable) { - * // process response - * } - * ``` - */ - listLocationsAsync( - request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions - ): AsyncIterable { - return this.locationsClient.listLocationsAsync(request, options); - } - -/** - * Gets the latest state of a long-running operation. Clients can use this - * method to poll the operation result at intervals as recommended by the API - * service. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error, ?Object)=} callback - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * const name = ''; - * const [response] = await client.getOperation({name}); - * // doThingsWith(response) - * ``` - */ - getOperation( - request: protos.google.longrunning.GetOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - > - ): Promise<[protos.google.longrunning.Operation]> { - return this.operationsClient.getOperation(request, options, callback); - } - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. - * - * For-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation collection. - * @param {string} request.filter - The standard list filter. - * @param {number=} request.pageSize - - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @returns {Object} - * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * for await (const response of client.listOperationsAsync(request)); - * // doThingsWith(response) - * ``` - */ - listOperationsAsync( - request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions - ): AsyncIterable { - return this.operationsClient.listOperationsAsync(request, options); - } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * {@link Operations.GetOperation} or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an {@link Operation.error} value with a {@link google.rpc.Status.code} of - * 1, corresponding to `Code.CANCELLED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be cancelled. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.cancelOperation({name: ''}); - * ``` - */ - cancelOperation( - request: protos.google.longrunning.CancelOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.CancelOperationRequest, - {} | undefined | null - >, - callback?: Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - > - ): Promise { - return this.operationsClient.cancelOperation(request, options, callback); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be deleted. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.deleteOperation({name: ''}); - * ``` - */ - deleteOperation( - request: protos.google.longrunning.DeleteOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - > - ): Promise { - return this.operationsClient.deleteOperation(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified 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 experiment resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} experiment - * @returns {string} Resource name string. - */ - experimentPath(project:string,location:string,catalog:string,experiment:string) { - return this.pathTemplates.experimentPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - experiment: experiment, - }); - } - - /** - * Parse the project from Experiment resource. - * - * @param {string} experimentName - * A fully-qualified path representing Experiment resource. - * @returns {string} A string representing the project. - */ - matchProjectFromExperimentName(experimentName: string) { - return this.pathTemplates.experimentPathTemplate.match(experimentName).project; - } - - /** - * Parse the location from Experiment resource. - * - * @param {string} experimentName - * A fully-qualified path representing Experiment resource. - * @returns {string} A string representing the location. - */ - matchLocationFromExperimentName(experimentName: string) { - return this.pathTemplates.experimentPathTemplate.match(experimentName).location; - } - - /** - * Parse the catalog from Experiment resource. - * - * @param {string} experimentName - * A fully-qualified path representing Experiment resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromExperimentName(experimentName: string) { - return this.pathTemplates.experimentPathTemplate.match(experimentName).catalog; - } - - /** - * Parse the experiment from Experiment resource. - * - * @param {string} experimentName - * A fully-qualified path representing Experiment resource. - * @returns {string} A string representing the experiment. - */ - matchExperimentFromExperimentName(experimentName: string) { - return this.pathTemplates.experimentPathTemplate.match(experimentName).experiment; - } - - /** - * Return a fully-qualified merchantCenterAccountLink resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} merchant_center_account_link - * @returns {string} Resource name string. - */ - merchantCenterAccountLinkPath(project:string,location:string,catalog:string,merchantCenterAccountLink:string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - merchant_center_account_link: merchantCenterAccountLink, - }); - } - - /** - * Parse the project from MerchantCenterAccountLink resource. - * - * @param {string} merchantCenterAccountLinkName - * A fully-qualified path representing MerchantCenterAccountLink resource. - * @returns {string} A string representing the project. - */ - matchProjectFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).project; - } - - /** - * Parse the location from MerchantCenterAccountLink resource. - * - * @param {string} merchantCenterAccountLinkName - * A fully-qualified path representing MerchantCenterAccountLink resource. - * @returns {string} A string representing the location. - */ - matchLocationFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).location; - } - - /** - * Parse the catalog from MerchantCenterAccountLink resource. - * - * @param {string} merchantCenterAccountLinkName - * A fully-qualified path representing MerchantCenterAccountLink resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).catalog; - } - - /** - * Parse the merchant_center_account_link from MerchantCenterAccountLink resource. - * - * @param {string} merchantCenterAccountLinkName - * A fully-qualified path representing MerchantCenterAccountLink resource. - * @returns {string} A string representing the merchant_center_account_link. - */ - matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).merchant_center_account_link; - } - - /** - * Return a fully-qualified model resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} model - * @returns {string} Resource name string. - */ - modelPath(project:string,location:string,catalog:string,model:string) { - return this.pathTemplates.modelPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - model: model, - }); - } - - /** - * Parse the project from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the project. - */ - matchProjectFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).project; - } - - /** - * Parse the location from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the location. - */ - matchLocationFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).location; - } - - /** - * Parse the catalog from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).catalog; - } - - /** - * Parse the model from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the model. - */ - matchModelFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).model; - } - - /** - * 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(); - this.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/search_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/search_service_client_config.json deleted file mode 100644 index 71a5a478c8c..00000000000 --- a/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2alpha/src/v2alpha/search_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/search_service_proto_list.json deleted file mode 100644 index b794e38509a..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/search_service_proto_list.json +++ /dev/null @@ -1,24 +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/merchant_center_account_link.proto", - "../../protos/google/cloud/retail/v2alpha/merchant_center_account_link_service.proto", - "../../protos/google/cloud/retail/v2alpha/model.proto", - "../../protos/google/cloud/retail/v2alpha/model_service.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/google-cloud-retail/v2alpha/src/v2alpha/serving_config_service_client.ts b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/serving_config_service_client.ts deleted file mode 100644 index 444c27ebeea..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/serving_config_service_client.ts +++ /dev/null @@ -1,1759 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/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}; - locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - 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/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new ServingConfigServiceClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof 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); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - this.locationsClient = new this._gaxModule.LocationsClient( - this._gaxGrpc, - opts - ); - - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - 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}' - ), - merchantCenterAccountLinkPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/merchantCenterAccountLinks/{merchant_center_account_link}' - ), - modelPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' - ), - 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') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',additional_bindings: [{get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/places/*/operations/*}',},{get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2alpha/{name=projects/*/locations/*/operations/*}',},{get: '/v2alpha/{name=projects/*/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2alpha/{name=projects/*/locations/*/catalogs/*}/operations',additional_bindings: [{get: '/v2alpha/{name=projects/*/locations/*}/operations',},{get: '/v2alpha/{name=projects/*}/operations',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - - this.descriptors.longrunning = { - }; - - // 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 = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.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._opts.fallback - ); - - 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 {@link google.cloud.retail.v2alpha.ServingConfig | 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' - ] = this._gaxModule.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 {@link google.protobuf.Empty | 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' - ] = this._gaxModule.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 {@link google.cloud.retail.v2alpha.ServingConfig | 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' - ] = this._gaxModule.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 {@link google.cloud.retail.v2alpha.ServingConfig | 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' - ] = this._gaxModule.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 {@link google.cloud.retail.v2alpha.ServingConfig | 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' - ] = this._gaxModule.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 {@link google.cloud.retail.v2alpha.ServingConfig | 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' - ] = this._gaxModule.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 {@link google.cloud.retail.v2alpha.ServingConfig | 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' - ] = this._gaxModule.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 {@link google.cloud.retail.v2alpha.ServingConfig | 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' - ] = this._gaxModule.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 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 - * {@link google.cloud.retail.v2alpha.ServingConfig | 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' - ] = this._gaxModule.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 {}, - callSettings - ) as AsyncIterable; - } -/** - * Gets information about a location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Resource name for the location. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * ``` - * const [response] = await client.getLocation(request); - * ``` - */ - getLocation( - request: LocationProtos.google.cloud.location.IGetLocationRequest, - options?: - | gax.CallOptions - | Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - > - ): Promise { - return this.locationsClient.getLocation(request, options, callback); - } - -/** - * Lists information about the supported locations for this service. Returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The resource that owns the locations collection, if applicable. - * @param {string} request.filter - * The standard list filter. - * @param {number} request.pageSize - * The standard list page size. - * @param {string} request.pageToken - * The standard list page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example - * ``` - * const iterable = client.listLocationsAsync(request); - * for await (const response of iterable) { - * // process response - * } - * ``` - */ - listLocationsAsync( - request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions - ): AsyncIterable { - return this.locationsClient.listLocationsAsync(request, options); - } - -/** - * Gets the latest state of a long-running operation. Clients can use this - * method to poll the operation result at intervals as recommended by the API - * service. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error, ?Object)=} callback - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * const name = ''; - * const [response] = await client.getOperation({name}); - * // doThingsWith(response) - * ``` - */ - getOperation( - request: protos.google.longrunning.GetOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - > - ): Promise<[protos.google.longrunning.Operation]> { - return this.operationsClient.getOperation(request, options, callback); - } - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. - * - * For-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation collection. - * @param {string} request.filter - The standard list filter. - * @param {number=} request.pageSize - - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @returns {Object} - * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * for await (const response of client.listOperationsAsync(request)); - * // doThingsWith(response) - * ``` - */ - listOperationsAsync( - request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions - ): AsyncIterable { - return this.operationsClient.listOperationsAsync(request, options); - } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * {@link Operations.GetOperation} or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an {@link Operation.error} value with a {@link google.rpc.Status.code} of - * 1, corresponding to `Code.CANCELLED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be cancelled. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.cancelOperation({name: ''}); - * ``` - */ - cancelOperation( - request: protos.google.longrunning.CancelOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.CancelOperationRequest, - {} | undefined | null - >, - callback?: Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - > - ): Promise { - return this.operationsClient.cancelOperation(request, options, callback); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be deleted. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.deleteOperation({name: ''}); - * ``` - */ - deleteOperation( - request: protos.google.longrunning.DeleteOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - > - ): Promise { - return this.operationsClient.deleteOperation(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified 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 merchantCenterAccountLink resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} merchant_center_account_link - * @returns {string} Resource name string. - */ - merchantCenterAccountLinkPath(project:string,location:string,catalog:string,merchantCenterAccountLink:string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - merchant_center_account_link: merchantCenterAccountLink, - }); - } - - /** - * Parse the project from MerchantCenterAccountLink resource. - * - * @param {string} merchantCenterAccountLinkName - * A fully-qualified path representing MerchantCenterAccountLink resource. - * @returns {string} A string representing the project. - */ - matchProjectFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).project; - } - - /** - * Parse the location from MerchantCenterAccountLink resource. - * - * @param {string} merchantCenterAccountLinkName - * A fully-qualified path representing MerchantCenterAccountLink resource. - * @returns {string} A string representing the location. - */ - matchLocationFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).location; - } - - /** - * Parse the catalog from MerchantCenterAccountLink resource. - * - * @param {string} merchantCenterAccountLinkName - * A fully-qualified path representing MerchantCenterAccountLink resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).catalog; - } - - /** - * Parse the merchant_center_account_link from MerchantCenterAccountLink resource. - * - * @param {string} merchantCenterAccountLinkName - * A fully-qualified path representing MerchantCenterAccountLink resource. - * @returns {string} A string representing the merchant_center_account_link. - */ - matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).merchant_center_account_link; - } - - /** - * Return a fully-qualified model resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} model - * @returns {string} Resource name string. - */ - modelPath(project:string,location:string,catalog:string,model:string) { - return this.pathTemplates.modelPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - model: model, - }); - } - - /** - * Parse the project from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the project. - */ - matchProjectFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).project; - } - - /** - * Parse the location from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the location. - */ - matchLocationFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).location; - } - - /** - * Parse the catalog from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).catalog; - } - - /** - * Parse the model from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the model. - */ - matchModelFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).model; - } - - /** - * 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(); - this.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/serving_config_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/serving_config_service_client_config.json deleted file mode 100644 index 6489c5db6ef..00000000000 --- a/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2alpha/src/v2alpha/serving_config_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/serving_config_service_proto_list.json deleted file mode 100644 index b794e38509a..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/serving_config_service_proto_list.json +++ /dev/null @@ -1,24 +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/merchant_center_account_link.proto", - "../../protos/google/cloud/retail/v2alpha/merchant_center_account_link_service.proto", - "../../protos/google/cloud/retail/v2alpha/model.proto", - "../../protos/google/cloud/retail/v2alpha/model_service.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/google-cloud-retail/v2alpha/src/v2alpha/user_event_service_client.ts b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/user_event_service_client.ts deleted file mode 100644 index d1c38c4d95b..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/user_event_service_client.ts +++ /dev/null @@ -1,1625 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, LocationsClient, LocationProtos} 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'; -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}; - locationsClient: LocationsClient; - 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/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new UserEventServiceClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof 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); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - this.locationsClient = new this._gaxModule.LocationsClient( - this._gaxGrpc, - opts - ); - - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - 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}' - ), - merchantCenterAccountLinkPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/merchantCenterAccountLinks/{merchant_center_account_link}' - ), - modelPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' - ), - 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. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',additional_bindings: [{get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/branches/*/places/*/operations/*}',},{get: '/v2alpha/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2alpha/{name=projects/*/locations/*/operations/*}',},{get: '/v2alpha/{name=projects/*/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2alpha/{name=projects/*/locations/*/catalogs/*}/operations',additional_bindings: [{get: '/v2alpha/{name=projects/*/locations/*}/operations',},{get: '/v2alpha/{name=projects/*}/operations',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).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 = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.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._opts.fallback - ); - - 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 {boolean} request.writeAsync - * If set to true, the user event will be written asynchronously after - * validation, and the API will respond without waiting for the write. - * Therefore, silent failures can occur even if the API returns success. In - * case of silent failures, error messages can be found in Stackdriver logs. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.retail.v2alpha.UserEvent | 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' - ] = this._gaxModule.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.prebuiltRule - * The prebuilt rule name that can convert a specific type of raw_json. - * For example: "ga4_bq" rule for the GA4 user event schema. - * @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 {string} request.rawJson - * An arbitrary serialized JSON string that contains necessary information - * that can comprise a user event. When this field is specified, the - * user_event field will be ignored. Note: line-delimited JSON is not - * supported, a single JSON only. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.api.HttpBody | 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' - ] = this._gaxModule.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' - ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.purgeUserEvents, this._gaxModule.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' - ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.importUserEvents, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Starts a user-event rejoin operation with latest product catalog. Events - * are not annotated with detailed product information for products that are - * missing from the catalog when the user event is ingested. These - * events are stored as unjoined events with limited usage on training and - * serving. You can use this method to start a join operation on specified - * events with the latest version of product catalog. You can also use this - * method 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' - ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.rejoinUserEvents, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Gets information about a location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Resource name for the location. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * ``` - * const [response] = await client.getLocation(request); - * ``` - */ - getLocation( - request: LocationProtos.google.cloud.location.IGetLocationRequest, - options?: - | gax.CallOptions - | Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - > - ): Promise { - return this.locationsClient.getLocation(request, options, callback); - } - -/** - * Lists information about the supported locations for this service. Returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The resource that owns the locations collection, if applicable. - * @param {string} request.filter - * The standard list filter. - * @param {number} request.pageSize - * The standard list page size. - * @param {string} request.pageToken - * The standard list page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example - * ``` - * const iterable = client.listLocationsAsync(request); - * for await (const response of iterable) { - * // process response - * } - * ``` - */ - listLocationsAsync( - request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions - ): AsyncIterable { - return this.locationsClient.listLocationsAsync(request, options); - } - -/** - * Gets the latest state of a long-running operation. Clients can use this - * method to poll the operation result at intervals as recommended by the API - * service. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error, ?Object)=} callback - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * const name = ''; - * const [response] = await client.getOperation({name}); - * // doThingsWith(response) - * ``` - */ - getOperation( - request: protos.google.longrunning.GetOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - > - ): Promise<[protos.google.longrunning.Operation]> { - return this.operationsClient.getOperation(request, options, callback); - } - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. - * - * For-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation collection. - * @param {string} request.filter - The standard list filter. - * @param {number=} request.pageSize - - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @returns {Object} - * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * for await (const response of client.listOperationsAsync(request)); - * // doThingsWith(response) - * ``` - */ - listOperationsAsync( - request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions - ): AsyncIterable { - return this.operationsClient.listOperationsAsync(request, options); - } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * {@link Operations.GetOperation} or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an {@link Operation.error} value with a {@link google.rpc.Status.code} of - * 1, corresponding to `Code.CANCELLED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be cancelled. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.cancelOperation({name: ''}); - * ``` - */ - cancelOperation( - request: protos.google.longrunning.CancelOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.CancelOperationRequest, - {} | undefined | null - >, - callback?: Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - > - ): Promise { - return this.operationsClient.cancelOperation(request, options, callback); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be deleted. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.deleteOperation({name: ''}); - * ``` - */ - deleteOperation( - request: protos.google.longrunning.DeleteOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - > - ): Promise { - return this.operationsClient.deleteOperation(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified 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 merchantCenterAccountLink resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} merchant_center_account_link - * @returns {string} Resource name string. - */ - merchantCenterAccountLinkPath(project:string,location:string,catalog:string,merchantCenterAccountLink:string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - merchant_center_account_link: merchantCenterAccountLink, - }); - } - - /** - * Parse the project from MerchantCenterAccountLink resource. - * - * @param {string} merchantCenterAccountLinkName - * A fully-qualified path representing MerchantCenterAccountLink resource. - * @returns {string} A string representing the project. - */ - matchProjectFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).project; - } - - /** - * Parse the location from MerchantCenterAccountLink resource. - * - * @param {string} merchantCenterAccountLinkName - * A fully-qualified path representing MerchantCenterAccountLink resource. - * @returns {string} A string representing the location. - */ - matchLocationFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).location; - } - - /** - * Parse the catalog from MerchantCenterAccountLink resource. - * - * @param {string} merchantCenterAccountLinkName - * A fully-qualified path representing MerchantCenterAccountLink resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).catalog; - } - - /** - * Parse the merchant_center_account_link from MerchantCenterAccountLink resource. - * - * @param {string} merchantCenterAccountLinkName - * A fully-qualified path representing MerchantCenterAccountLink resource. - * @returns {string} A string representing the merchant_center_account_link. - */ - matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName(merchantCenterAccountLinkName: string) { - return this.pathTemplates.merchantCenterAccountLinkPathTemplate.match(merchantCenterAccountLinkName).merchant_center_account_link; - } - - /** - * Return a fully-qualified model resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} model - * @returns {string} Resource name string. - */ - modelPath(project:string,location:string,catalog:string,model:string) { - return this.pathTemplates.modelPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - model: model, - }); - } - - /** - * Parse the project from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the project. - */ - matchProjectFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).project; - } - - /** - * Parse the location from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the location. - */ - matchLocationFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).location; - } - - /** - * Parse the catalog from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).catalog; - } - - /** - * Parse the model from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the model. - */ - matchModelFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).model; - } - - /** - * 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.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/user_event_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/user_event_service_client_config.json deleted file mode 100644 index 21dfac2e12b..00000000000 --- a/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2alpha/src/v2alpha/user_event_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/user_event_service_proto_list.json deleted file mode 100644 index b794e38509a..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/src/v2alpha/user_event_service_proto_list.json +++ /dev/null @@ -1,24 +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/merchant_center_account_link.proto", - "../../protos/google/cloud/retail/v2alpha/merchant_center_account_link_service.proto", - "../../protos/google/cloud/retail/v2alpha/model.proto", - "../../protos/google/cloud/retail/v2alpha/model_service.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/google-cloud-retail/v2alpha/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-retail/v2alpha/system-test/fixtures/sample/src/index.js deleted file mode 100644 index 54c40c9f65d..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** 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 merchantCenterAccountLinkServiceClient = new retail.MerchantCenterAccountLinkServiceClient(); - const modelServiceClient = new retail.ModelServiceClient(); - 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/google-cloud-retail/v2alpha/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-retail/v2alpha/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 5675c1ca814..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This 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, MerchantCenterAccountLinkServiceClient, ModelServiceClient, 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 doStuffWithMerchantCenterAccountLinkServiceClient(client: MerchantCenterAccountLinkServiceClient) { - client.close(); -} -function doStuffWithModelServiceClient(client: ModelServiceClient) { - 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 merchantCenterAccountLinkServiceClient = new MerchantCenterAccountLinkServiceClient(); - doStuffWithMerchantCenterAccountLinkServiceClient(merchantCenterAccountLinkServiceClient); - // check that the client instance can be created - const modelServiceClient = new ModelServiceClient(); - doStuffWithModelServiceClient(modelServiceClient); - // 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/google-cloud-retail/v2alpha/system-test/install.ts b/owl-bot-staging/google-cloud-retail/v2alpha/system-test/install.ts deleted file mode 100644 index c8f81b25a86..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/system-test/install.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import {packNTest} from 'pack-n-play'; -import {readFileSync} from 'fs'; -import {describe, it} from 'mocha'; - -describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } - }; - await packNTest(options); - }); - - it('JavaScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'JavaScript user can use the library', - ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } - }; - await packNTest(options); - }); - -}); diff --git a/owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_catalog_service_v2alpha.ts b/owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_catalog_service_v2alpha.ts deleted file mode 100644 index 08162257c4d..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_catalog_service_v2alpha.ts +++ /dev/null @@ -1,2574 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This 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, operationsProtos, LocationProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function 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', () => { - describe('Common methods', () => { - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateCatalogRequest', ['catalog', 'name']); - request.catalog.name = defaultValue1; - const expectedHeaderRequestParams = `catalog.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.updateCatalog as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCatalog as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateCatalogRequest', ['catalog', 'name']); - request.catalog.name = defaultValue1; - const expectedHeaderRequestParams = `catalog.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.updateCatalog as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCatalog as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateCatalogRequest', ['catalog', 'name']); - request.catalog.name = defaultValue1; - const expectedHeaderRequestParams = `catalog.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateCatalog = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateCatalog(request), expectedError); - const actualRequest = (client.innerApiCalls.updateCatalog as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCatalog as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateCatalogRequest', ['catalog', 'name']); - request.catalog.name = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.SetDefaultBranchRequest', ['catalog']); - request.catalog = defaultValue1; - const expectedHeaderRequestParams = `catalog=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.setDefaultBranch = stubSimpleCall(expectedResponse); - const [response] = await client.setDefaultBranch(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setDefaultBranch as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setDefaultBranch as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.SetDefaultBranchRequest', ['catalog']); - request.catalog = defaultValue1; - const expectedHeaderRequestParams = `catalog=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.setDefaultBranch as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setDefaultBranch as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.SetDefaultBranchRequest', ['catalog']); - request.catalog = defaultValue1; - const expectedHeaderRequestParams = `catalog=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.setDefaultBranch = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setDefaultBranch(request), expectedError); - const actualRequest = (client.innerApiCalls.setDefaultBranch as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setDefaultBranch as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.SetDefaultBranchRequest', ['catalog']); - request.catalog = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.GetDefaultBranchRequest', ['catalog']); - request.catalog = defaultValue1; - const expectedHeaderRequestParams = `catalog=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getDefaultBranch as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDefaultBranch as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.GetDefaultBranchRequest', ['catalog']); - request.catalog = defaultValue1; - const expectedHeaderRequestParams = `catalog=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getDefaultBranch as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDefaultBranch as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.GetDefaultBranchRequest', ['catalog']); - request.catalog = defaultValue1; - const expectedHeaderRequestParams = `catalog=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getDefaultBranch = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getDefaultBranch(request), expectedError); - const actualRequest = (client.innerApiCalls.getDefaultBranch as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDefaultBranch as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.GetDefaultBranchRequest', ['catalog']); - request.catalog = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.GetCompletionConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getCompletionConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCompletionConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.GetCompletionConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getCompletionConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCompletionConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.GetCompletionConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getCompletionConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getCompletionConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.getCompletionConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCompletionConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.GetCompletionConfigRequest', ['name']); - request.name = defaultValue1; - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateCompletionConfigRequest', ['completionConfig', 'name']); - request.completionConfig.name = defaultValue1; - const expectedHeaderRequestParams = `completion_config.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.updateCompletionConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCompletionConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateCompletionConfigRequest', ['completionConfig', 'name']); - request.completionConfig.name = defaultValue1; - const expectedHeaderRequestParams = `completion_config.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.updateCompletionConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCompletionConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateCompletionConfigRequest', ['completionConfig', 'name']); - request.completionConfig.name = defaultValue1; - const expectedHeaderRequestParams = `completion_config.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateCompletionConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateCompletionConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.updateCompletionConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCompletionConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateCompletionConfigRequest', ['completionConfig', 'name']); - request.completionConfig.name = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.GetAttributesConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getAttributesConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAttributesConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.GetAttributesConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getAttributesConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAttributesConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.GetAttributesConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getAttributesConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getAttributesConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.getAttributesConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAttributesConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.GetAttributesConfigRequest', ['name']); - request.name = defaultValue1; - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateAttributesConfigRequest', ['attributesConfig', 'name']); - request.attributesConfig.name = defaultValue1; - const expectedHeaderRequestParams = `attributes_config.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.updateAttributesConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateAttributesConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateAttributesConfigRequest', ['attributesConfig', 'name']); - request.attributesConfig.name = defaultValue1; - const expectedHeaderRequestParams = `attributes_config.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.updateAttributesConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateAttributesConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateAttributesConfigRequest', ['attributesConfig', 'name']); - request.attributesConfig.name = defaultValue1; - const expectedHeaderRequestParams = `attributes_config.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateAttributesConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateAttributesConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.updateAttributesConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateAttributesConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateAttributesConfigRequest', ['attributesConfig', 'name']); - request.attributesConfig.name = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.AddCatalogAttributeRequest', ['attributesConfig']); - request.attributesConfig = defaultValue1; - const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.addCatalogAttribute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addCatalogAttribute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.AddCatalogAttributeRequest', ['attributesConfig']); - request.attributesConfig = defaultValue1; - const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.addCatalogAttribute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addCatalogAttribute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.AddCatalogAttributeRequest', ['attributesConfig']); - request.attributesConfig = defaultValue1; - const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.addCatalogAttribute = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.addCatalogAttribute(request), expectedError); - const actualRequest = (client.innerApiCalls.addCatalogAttribute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addCatalogAttribute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.AddCatalogAttributeRequest', ['attributesConfig']); - request.attributesConfig = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest', ['attributesConfig']); - request.attributesConfig = defaultValue1; - const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.removeCatalogAttribute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeCatalogAttribute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest', ['attributesConfig']); - request.attributesConfig = defaultValue1; - const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.removeCatalogAttribute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeCatalogAttribute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest', ['attributesConfig']); - request.attributesConfig = defaultValue1; - const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.removeCatalogAttribute = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.removeCatalogAttribute(request), expectedError); - const actualRequest = (client.innerApiCalls.removeCatalogAttribute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeCatalogAttribute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.RemoveCatalogAttributeRequest', ['attributesConfig']); - request.attributesConfig = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.removeCatalogAttribute(request), expectedError); - }); - }); - - describe('batchRemoveCatalogAttributes', () => { - it('invokes batchRemoveCatalogAttributes 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.BatchRemoveCatalogAttributesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.BatchRemoveCatalogAttributesRequest', ['attributesConfig']); - request.attributesConfig = defaultValue1; - const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.BatchRemoveCatalogAttributesResponse() - ); - client.innerApiCalls.batchRemoveCatalogAttributes = stubSimpleCall(expectedResponse); - const [response] = await client.batchRemoveCatalogAttributes(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.batchRemoveCatalogAttributes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchRemoveCatalogAttributes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes batchRemoveCatalogAttributes 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.BatchRemoveCatalogAttributesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.BatchRemoveCatalogAttributesRequest', ['attributesConfig']); - request.attributesConfig = defaultValue1; - const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.BatchRemoveCatalogAttributesResponse() - ); - client.innerApiCalls.batchRemoveCatalogAttributes = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchRemoveCatalogAttributes( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IBatchRemoveCatalogAttributesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.batchRemoveCatalogAttributes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchRemoveCatalogAttributes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes batchRemoveCatalogAttributes 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.BatchRemoveCatalogAttributesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.BatchRemoveCatalogAttributesRequest', ['attributesConfig']); - request.attributesConfig = defaultValue1; - const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.batchRemoveCatalogAttributes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.batchRemoveCatalogAttributes(request), expectedError); - const actualRequest = (client.innerApiCalls.batchRemoveCatalogAttributes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchRemoveCatalogAttributes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes batchRemoveCatalogAttributes 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.BatchRemoveCatalogAttributesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.BatchRemoveCatalogAttributesRequest', ['attributesConfig']); - request.attributesConfig = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.batchRemoveCatalogAttributes(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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest', ['attributesConfig']); - request.attributesConfig = defaultValue1; - const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.replaceCatalogAttribute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.replaceCatalogAttribute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest', ['attributesConfig']); - request.attributesConfig = defaultValue1; - const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.replaceCatalogAttribute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.replaceCatalogAttribute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest', ['attributesConfig']); - request.attributesConfig = defaultValue1; - const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.replaceCatalogAttribute = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.replaceCatalogAttribute(request), expectedError); - const actualRequest = (client.innerApiCalls.replaceCatalogAttribute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.replaceCatalogAttribute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ReplaceCatalogAttributeRequest', ['attributesConfig']); - request.attributesConfig = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ListCatalogsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.listCatalogs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCatalogs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ListCatalogsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.listCatalogs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCatalogs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ListCatalogsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listCatalogs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listCatalogs(request), expectedError); - const actualRequest = (client.innerApiCalls.listCatalogs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCatalogs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ListCatalogsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listCatalogs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ListCatalogsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listCatalogs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ListCatalogsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ListCatalogsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('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('merchantCenterAccountLink', () => { - const fakePath = "/rendered/path/merchantCenterAccountLink"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - merchant_center_account_link: "merchantCenterAccountLinkValue", - }; - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.merchantCenterAccountLinkPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.merchantCenterAccountLinkPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('merchantCenterAccountLinkPath', () => { - const result = client.merchantCenterAccountLinkPath("projectValue", "locationValue", "catalogValue", "merchantCenterAccountLinkValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromMerchantCenterAccountLinkName', () => { - const result = client.matchProjectFromMerchantCenterAccountLinkName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromMerchantCenterAccountLinkName', () => { - const result = client.matchLocationFromMerchantCenterAccountLinkName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromMerchantCenterAccountLinkName', () => { - const result = client.matchCatalogFromMerchantCenterAccountLinkName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName', () => { - const result = client.matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName(fakePath); - assert.strictEqual(result, "merchantCenterAccountLinkValue"); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('model', () => { - const fakePath = "/rendered/path/model"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - model: "modelValue", - }; - const client = new catalogserviceModule.v2alpha.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.modelPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.modelPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('modelPath', () => { - const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.modelPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromModelName', () => { - const result = client.matchProjectFromModelName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromModelName', () => { - const result = client.matchLocationFromModelName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromModelName', () => { - const result = client.matchCatalogFromModelName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchModelFromModelName', () => { - const result = client.matchModelFromModelName(fakePath); - assert.strictEqual(result, "modelValue"); - assert((client.pathTemplates.modelPathTemplate.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/google-cloud-retail/v2alpha/test/gapic_completion_service_v2alpha.ts b/owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_completion_service_v2alpha.ts deleted file mode 100644 index 0c394879563..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_completion_service_v2alpha.ts +++ /dev/null @@ -1,1288 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This 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, LocationProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function 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.CompletionServiceClient', () => { - describe('Common methods', () => { - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.CompleteQueryRequest', ['catalog']); - request.catalog = defaultValue1; - const expectedHeaderRequestParams = `catalog=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.CompleteQueryRequest', ['catalog']); - request.catalog = defaultValue1; - const expectedHeaderRequestParams = `catalog=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.CompleteQueryRequest', ['catalog']); - request.catalog = defaultValue1; - const expectedHeaderRequestParams = `catalog=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.completeQuery = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.completeQuery(request), expectedError); - const actualRequest = (client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.CompleteQueryRequest', ['catalog']); - request.catalog = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ImportCompletionDataRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.importCompletionData as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importCompletionData as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ImportCompletionDataRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.importCompletionData as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importCompletionData as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ImportCompletionDataRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importCompletionData = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importCompletionData(request), expectedError); - const actualRequest = (client.innerApiCalls.importCompletionData as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importCompletionData as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ImportCompletionDataRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importCompletionData = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importCompletionData(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.importCompletionData as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importCompletionData as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('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('merchantCenterAccountLink', () => { - const fakePath = "/rendered/path/merchantCenterAccountLink"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - merchant_center_account_link: "merchantCenterAccountLinkValue", - }; - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.merchantCenterAccountLinkPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.merchantCenterAccountLinkPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('merchantCenterAccountLinkPath', () => { - const result = client.merchantCenterAccountLinkPath("projectValue", "locationValue", "catalogValue", "merchantCenterAccountLinkValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromMerchantCenterAccountLinkName', () => { - const result = client.matchProjectFromMerchantCenterAccountLinkName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromMerchantCenterAccountLinkName', () => { - const result = client.matchLocationFromMerchantCenterAccountLinkName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromMerchantCenterAccountLinkName', () => { - const result = client.matchCatalogFromMerchantCenterAccountLinkName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName', () => { - const result = client.matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName(fakePath); - assert.strictEqual(result, "merchantCenterAccountLinkValue"); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('model', () => { - const fakePath = "/rendered/path/model"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - model: "modelValue", - }; - const client = new completionserviceModule.v2alpha.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.modelPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.modelPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('modelPath', () => { - const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.modelPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromModelName', () => { - const result = client.matchProjectFromModelName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromModelName', () => { - const result = client.matchLocationFromModelName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromModelName', () => { - const result = client.matchCatalogFromModelName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchModelFromModelName', () => { - const result = client.matchModelFromModelName(fakePath); - assert.strictEqual(result, "modelValue"); - assert((client.pathTemplates.modelPathTemplate.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/google-cloud-retail/v2alpha/test/gapic_control_service_v2alpha.ts b/owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_control_service_v2alpha.ts deleted file mode 100644 index 516086cb2d4..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_control_service_v2alpha.ts +++ /dev/null @@ -1,1718 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This 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, operationsProtos, LocationProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function 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', () => { - describe('Common methods', () => { - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.CreateControlRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.createControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.CreateControlRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.createControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.CreateControlRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createControl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createControl(request), expectedError); - const actualRequest = (client.innerApiCalls.createControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.CreateControlRequest', ['parent']); - request.parent = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.DeleteControlRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteControl = stubSimpleCall(expectedResponse); - const [response] = await client.deleteControl(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.DeleteControlRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.deleteControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.DeleteControlRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteControl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteControl(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.DeleteControlRequest', ['name']); - request.name = defaultValue1; - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateControlRequest', ['control', 'name']); - request.control.name = defaultValue1; - const expectedHeaderRequestParams = `control.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.updateControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateControlRequest', ['control', 'name']); - request.control.name = defaultValue1; - const expectedHeaderRequestParams = `control.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.updateControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateControlRequest', ['control', 'name']); - request.control.name = defaultValue1; - const expectedHeaderRequestParams = `control.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateControl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateControl(request), expectedError); - const actualRequest = (client.innerApiCalls.updateControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateControlRequest', ['control', 'name']); - request.control.name = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.GetControlRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.GetControlRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.GetControlRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getControl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getControl(request), expectedError); - const actualRequest = (client.innerApiCalls.getControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.GetControlRequest', ['name']); - request.name = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ListControlsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.listControls as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listControls as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ListControlsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.listControls as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listControls as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ListControlsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listControls = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listControls(request), expectedError); - const actualRequest = (client.innerApiCalls.listControls as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listControls as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ListControlsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listControls.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ListControlsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listControls.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ListControlsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listControls.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ListControlsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listControls.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('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('merchantCenterAccountLink', () => { - const fakePath = "/rendered/path/merchantCenterAccountLink"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - merchant_center_account_link: "merchantCenterAccountLinkValue", - }; - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.merchantCenterAccountLinkPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.merchantCenterAccountLinkPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('merchantCenterAccountLinkPath', () => { - const result = client.merchantCenterAccountLinkPath("projectValue", "locationValue", "catalogValue", "merchantCenterAccountLinkValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromMerchantCenterAccountLinkName', () => { - const result = client.matchProjectFromMerchantCenterAccountLinkName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromMerchantCenterAccountLinkName', () => { - const result = client.matchLocationFromMerchantCenterAccountLinkName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromMerchantCenterAccountLinkName', () => { - const result = client.matchCatalogFromMerchantCenterAccountLinkName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName', () => { - const result = client.matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName(fakePath); - assert.strictEqual(result, "merchantCenterAccountLinkValue"); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('model', () => { - const fakePath = "/rendered/path/model"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - model: "modelValue", - }; - const client = new controlserviceModule.v2alpha.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.modelPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.modelPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('modelPath', () => { - const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.modelPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromModelName', () => { - const result = client.matchProjectFromModelName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromModelName', () => { - const result = client.matchLocationFromModelName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromModelName', () => { - const result = client.matchCatalogFromModelName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchModelFromModelName', () => { - const result = client.matchModelFromModelName(fakePath); - assert.strictEqual(result, "modelValue"); - assert((client.pathTemplates.modelPathTemplate.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/google-cloud-retail/v2alpha/test/gapic_merchant_center_account_link_service_v2alpha.ts b/owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_merchant_center_account_link_service_v2alpha.ts deleted file mode 100644 index fbfe6d23560..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_merchant_center_account_link_service_v2alpha.ts +++ /dev/null @@ -1,1396 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This 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 merchantcenteraccountlinkserviceModule from '../src'; - -import {protobuf, LROperation, operationsProtos, LocationProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function 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.MerchantCenterAccountLinkServiceClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.merchantCenterAccountLinkServiceStub, undefined); - await client.initialize(); - assert(client.merchantCenterAccountLinkServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.merchantCenterAccountLinkServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.merchantCenterAccountLinkServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ - 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 merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ - 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('listMerchantCenterAccountLinks', () => { - it('invokes listMerchantCenterAccountLinks without error', async () => { - const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.ListMerchantCenterAccountLinksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ListMerchantCenterAccountLinksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.ListMerchantCenterAccountLinksResponse() - ); - client.innerApiCalls.listMerchantCenterAccountLinks = stubSimpleCall(expectedResponse); - const [response] = await client.listMerchantCenterAccountLinks(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listMerchantCenterAccountLinks as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMerchantCenterAccountLinks as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listMerchantCenterAccountLinks without error using callback', async () => { - const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.ListMerchantCenterAccountLinksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ListMerchantCenterAccountLinksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.ListMerchantCenterAccountLinksResponse() - ); - client.innerApiCalls.listMerchantCenterAccountLinks = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listMerchantCenterAccountLinks( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IListMerchantCenterAccountLinksResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listMerchantCenterAccountLinks as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMerchantCenterAccountLinks as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listMerchantCenterAccountLinks with error', async () => { - const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.ListMerchantCenterAccountLinksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ListMerchantCenterAccountLinksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listMerchantCenterAccountLinks = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listMerchantCenterAccountLinks(request), expectedError); - const actualRequest = (client.innerApiCalls.listMerchantCenterAccountLinks as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMerchantCenterAccountLinks as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listMerchantCenterAccountLinks with closed client', async () => { - const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.ListMerchantCenterAccountLinksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ListMerchantCenterAccountLinksRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.listMerchantCenterAccountLinks(request), expectedError); - }); - }); - - describe('deleteMerchantCenterAccountLink', () => { - it('invokes deleteMerchantCenterAccountLink without error', async () => { - const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.DeleteMerchantCenterAccountLinkRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.DeleteMerchantCenterAccountLinkRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteMerchantCenterAccountLink = stubSimpleCall(expectedResponse); - const [response] = await client.deleteMerchantCenterAccountLink(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteMerchantCenterAccountLink as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteMerchantCenterAccountLink as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteMerchantCenterAccountLink without error using callback', async () => { - const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.DeleteMerchantCenterAccountLinkRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.DeleteMerchantCenterAccountLinkRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteMerchantCenterAccountLink = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteMerchantCenterAccountLink( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteMerchantCenterAccountLink as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteMerchantCenterAccountLink as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteMerchantCenterAccountLink with error', async () => { - const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.DeleteMerchantCenterAccountLinkRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.DeleteMerchantCenterAccountLinkRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteMerchantCenterAccountLink = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteMerchantCenterAccountLink(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteMerchantCenterAccountLink as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteMerchantCenterAccountLink as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteMerchantCenterAccountLink with closed client', async () => { - const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.DeleteMerchantCenterAccountLinkRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.DeleteMerchantCenterAccountLinkRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteMerchantCenterAccountLink(request), expectedError); - }); - }); - - describe('createMerchantCenterAccountLink', () => { - it('invokes createMerchantCenterAccountLink without error', async () => { - const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.CreateMerchantCenterAccountLinkRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.CreateMerchantCenterAccountLinkRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createMerchantCenterAccountLink = stubLongRunningCall(expectedResponse); - const [operation] = await client.createMerchantCenterAccountLink(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createMerchantCenterAccountLink as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMerchantCenterAccountLink as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createMerchantCenterAccountLink without error using callback', async () => { - const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.CreateMerchantCenterAccountLinkRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.CreateMerchantCenterAccountLinkRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createMerchantCenterAccountLink = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createMerchantCenterAccountLink( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createMerchantCenterAccountLink as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMerchantCenterAccountLink as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createMerchantCenterAccountLink with call error', async () => { - const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.CreateMerchantCenterAccountLinkRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.CreateMerchantCenterAccountLinkRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createMerchantCenterAccountLink = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createMerchantCenterAccountLink(request), expectedError); - const actualRequest = (client.innerApiCalls.createMerchantCenterAccountLink as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMerchantCenterAccountLink as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createMerchantCenterAccountLink with LRO error', async () => { - const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.CreateMerchantCenterAccountLinkRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.CreateMerchantCenterAccountLinkRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createMerchantCenterAccountLink = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createMerchantCenterAccountLink(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createMerchantCenterAccountLink as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMerchantCenterAccountLink as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateMerchantCenterAccountLinkProgress without error', async () => { - const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateMerchantCenterAccountLinkProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateMerchantCenterAccountLinkProgress with error', async () => { - const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateMerchantCenterAccountLinkProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('attributesConfig', () => { - const fakePath = "/rendered/path/attributesConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ - 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 merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ - 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 merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ - 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 merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ - 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('merchantCenterAccountLink', () => { - const fakePath = "/rendered/path/merchantCenterAccountLink"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - merchant_center_account_link: "merchantCenterAccountLinkValue", - }; - const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.merchantCenterAccountLinkPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.merchantCenterAccountLinkPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('merchantCenterAccountLinkPath', () => { - const result = client.merchantCenterAccountLinkPath("projectValue", "locationValue", "catalogValue", "merchantCenterAccountLinkValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromMerchantCenterAccountLinkName', () => { - const result = client.matchProjectFromMerchantCenterAccountLinkName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromMerchantCenterAccountLinkName', () => { - const result = client.matchLocationFromMerchantCenterAccountLinkName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromMerchantCenterAccountLinkName', () => { - const result = client.matchCatalogFromMerchantCenterAccountLinkName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName', () => { - const result = client.matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName(fakePath); - assert.strictEqual(result, "merchantCenterAccountLinkValue"); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('model', () => { - const fakePath = "/rendered/path/model"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - model: "modelValue", - }; - const client = new merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.modelPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.modelPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('modelPath', () => { - const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.modelPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromModelName', () => { - const result = client.matchProjectFromModelName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromModelName', () => { - const result = client.matchLocationFromModelName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromModelName', () => { - const result = client.matchCatalogFromModelName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchModelFromModelName', () => { - const result = client.matchModelFromModelName(fakePath); - assert.strictEqual(result, "modelValue"); - assert((client.pathTemplates.modelPathTemplate.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 merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ - 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 merchantcenteraccountlinkserviceModule.v2alpha.MerchantCenterAccountLinkServiceClient({ - 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/google-cloud-retail/v2alpha/test/gapic_model_service_v2alpha.ts b/owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_model_service_v2alpha.ts deleted file mode 100644 index b44a338af49..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_model_service_v2alpha.ts +++ /dev/null @@ -1,2150 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This 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 modelserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos, LocationProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v2alpha.ModelServiceClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = modelserviceModule.v2alpha.ModelServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = modelserviceModule.v2alpha.ModelServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = modelserviceModule.v2alpha.ModelServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.modelServiceStub, undefined); - await client.initialize(); - assert(client.modelServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.modelServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.modelServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - 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 modelserviceModule.v2alpha.ModelServiceClient({ - 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('getModel', () => { - it('invokes getModel without error', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.GetModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.GetModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.Model() - ); - client.innerApiCalls.getModel = stubSimpleCall(expectedResponse); - const [response] = await client.getModel(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getModel without error using callback', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.GetModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.GetModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.Model() - ); - client.innerApiCalls.getModel = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getModel( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IModel|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getModel with error', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.GetModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.GetModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getModel = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getModel(request), expectedError); - const actualRequest = (client.innerApiCalls.getModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getModel with closed client', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.GetModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.GetModelRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getModel(request), expectedError); - }); - }); - - describe('pauseModel', () => { - it('invokes pauseModel without error', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.PauseModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.PauseModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.Model() - ); - client.innerApiCalls.pauseModel = stubSimpleCall(expectedResponse); - const [response] = await client.pauseModel(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.pauseModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pauseModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes pauseModel without error using callback', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.PauseModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.PauseModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.Model() - ); - client.innerApiCalls.pauseModel = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.pauseModel( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IModel|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.pauseModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pauseModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes pauseModel with error', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.PauseModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.PauseModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.pauseModel = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.pauseModel(request), expectedError); - const actualRequest = (client.innerApiCalls.pauseModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pauseModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes pauseModel with closed client', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.PauseModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.PauseModelRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.pauseModel(request), expectedError); - }); - }); - - describe('resumeModel', () => { - it('invokes resumeModel without error', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.ResumeModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ResumeModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.Model() - ); - client.innerApiCalls.resumeModel = stubSimpleCall(expectedResponse); - const [response] = await client.resumeModel(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resumeModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resumeModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resumeModel without error using callback', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.ResumeModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ResumeModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.Model() - ); - client.innerApiCalls.resumeModel = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.resumeModel( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IModel|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resumeModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resumeModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resumeModel with error', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.ResumeModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ResumeModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.resumeModel = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.resumeModel(request), expectedError); - const actualRequest = (client.innerApiCalls.resumeModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resumeModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resumeModel with closed client', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.ResumeModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ResumeModelRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.resumeModel(request), expectedError); - }); - }); - - describe('deleteModel', () => { - it('invokes deleteModel without error', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.DeleteModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.DeleteModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteModel = stubSimpleCall(expectedResponse); - const [response] = await client.deleteModel(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteModel without error using callback', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.DeleteModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.DeleteModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteModel = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteModel( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteModel with error', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.DeleteModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.DeleteModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteModel = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteModel(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteModel with closed client', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.DeleteModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.DeleteModelRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteModel(request), expectedError); - }); - }); - - describe('updateModel', () => { - it('invokes updateModel without error', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.UpdateModelRequest() - ); - request.model ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateModelRequest', ['model', 'name']); - request.model.name = defaultValue1; - const expectedHeaderRequestParams = `model.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.Model() - ); - client.innerApiCalls.updateModel = stubSimpleCall(expectedResponse); - const [response] = await client.updateModel(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateModel without error using callback', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.UpdateModelRequest() - ); - request.model ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateModelRequest', ['model', 'name']); - request.model.name = defaultValue1; - const expectedHeaderRequestParams = `model.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.Model() - ); - client.innerApiCalls.updateModel = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateModel( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IModel|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateModel with error', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.UpdateModelRequest() - ); - request.model ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateModelRequest', ['model', 'name']); - request.model.name = defaultValue1; - const expectedHeaderRequestParams = `model.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateModel = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateModel(request), expectedError); - const actualRequest = (client.innerApiCalls.updateModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateModel with closed client', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.UpdateModelRequest() - ); - request.model ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateModelRequest', ['model', 'name']); - request.model.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateModel(request), expectedError); - }); - }); - - describe('createModel', () => { - it('invokes createModel without error', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.CreateModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.CreateModelRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createModel = stubLongRunningCall(expectedResponse); - const [operation] = await client.createModel(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createModel without error using callback', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.CreateModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.CreateModelRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createModel = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createModel( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createModel with call error', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.CreateModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.CreateModelRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createModel = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createModel(request), expectedError); - const actualRequest = (client.innerApiCalls.createModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createModel with LRO error', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.CreateModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.CreateModelRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createModel = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createModel(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateModelProgress without error', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateModelProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateModelProgress with error', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateModelProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('tuneModel', () => { - it('invokes tuneModel without error', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.TuneModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.TuneModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.tuneModel = stubLongRunningCall(expectedResponse); - const [operation] = await client.tuneModel(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.tuneModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.tuneModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes tuneModel without error using callback', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.TuneModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.TuneModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.tuneModel = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.tuneModel( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.tuneModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.tuneModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes tuneModel with call error', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.TuneModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.TuneModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.tuneModel = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.tuneModel(request), expectedError); - const actualRequest = (client.innerApiCalls.tuneModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.tuneModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes tuneModel with LRO error', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.TuneModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.TuneModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.tuneModel = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.tuneModel(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.tuneModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.tuneModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkTuneModelProgress without error', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkTuneModelProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkTuneModelProgress with error', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkTuneModelProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listModels', () => { - it('invokes listModels without error', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.ListModelsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ListModelsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Model()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Model()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Model()), - ]; - client.innerApiCalls.listModels = stubSimpleCall(expectedResponse); - const [response] = await client.listModels(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listModels as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listModels as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listModels without error using callback', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.ListModelsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ListModelsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Model()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Model()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Model()), - ]; - client.innerApiCalls.listModels = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listModels( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2alpha.IModel[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listModels as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listModels as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listModels with error', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.ListModelsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ListModelsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listModels = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listModels(request), expectedError); - const actualRequest = (client.innerApiCalls.listModels as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listModels as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listModelsStream without error', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.ListModelsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ListModelsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Model()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Model()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Model()), - ]; - client.descriptors.page.listModels.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listModelsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2alpha.Model[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2alpha.Model) => { - 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.listModels.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listModels, request)); - assert( - (client.descriptors.page.listModels.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listModelsStream with error', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.ListModelsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ListModelsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listModels.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listModelsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2alpha.Model[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2alpha.Model) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listModels.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listModels, request)); - assert( - (client.descriptors.page.listModels.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listModels without error', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.ListModelsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ListModelsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Model()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Model()), - generateSampleMessage(new protos.google.cloud.retail.v2alpha.Model()), - ]; - client.descriptors.page.listModels.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.retail.v2alpha.IModel[] = []; - const iterable = client.listModelsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listModels.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listModels.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listModels with error', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.ListModelsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ListModelsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listModels.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listModelsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.retail.v2alpha.IModel[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listModels.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listModels.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('attributesConfig', () => { - const fakePath = "/rendered/path/attributesConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - 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 modelserviceModule.v2alpha.ModelServiceClient({ - 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 modelserviceModule.v2alpha.ModelServiceClient({ - 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 modelserviceModule.v2alpha.ModelServiceClient({ - 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('merchantCenterAccountLink', () => { - const fakePath = "/rendered/path/merchantCenterAccountLink"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - merchant_center_account_link: "merchantCenterAccountLinkValue", - }; - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.merchantCenterAccountLinkPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.merchantCenterAccountLinkPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('merchantCenterAccountLinkPath', () => { - const result = client.merchantCenterAccountLinkPath("projectValue", "locationValue", "catalogValue", "merchantCenterAccountLinkValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromMerchantCenterAccountLinkName', () => { - const result = client.matchProjectFromMerchantCenterAccountLinkName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromMerchantCenterAccountLinkName', () => { - const result = client.matchLocationFromMerchantCenterAccountLinkName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromMerchantCenterAccountLinkName', () => { - const result = client.matchCatalogFromMerchantCenterAccountLinkName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName', () => { - const result = client.matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName(fakePath); - assert.strictEqual(result, "merchantCenterAccountLinkValue"); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('model', () => { - const fakePath = "/rendered/path/model"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - model: "modelValue", - }; - const client = new modelserviceModule.v2alpha.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.modelPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.modelPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('modelPath', () => { - const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.modelPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromModelName', () => { - const result = client.matchProjectFromModelName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromModelName', () => { - const result = client.matchLocationFromModelName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromModelName', () => { - const result = client.matchCatalogFromModelName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchModelFromModelName', () => { - const result = client.matchModelFromModelName(fakePath); - assert.strictEqual(result, "modelValue"); - assert((client.pathTemplates.modelPathTemplate.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 modelserviceModule.v2alpha.ModelServiceClient({ - 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 modelserviceModule.v2alpha.ModelServiceClient({ - 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/google-cloud-retail/v2alpha/test/gapic_prediction_service_v2alpha.ts b/owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_prediction_service_v2alpha.ts deleted file mode 100644 index ba576dee231..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_prediction_service_v2alpha.ts +++ /dev/null @@ -1,1118 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This 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, operationsProtos, LocationProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function 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.PredictionServiceClient', () => { - describe('Common methods', () => { - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.PredictRequest', ['placement']); - request.placement = defaultValue1; - const expectedHeaderRequestParams = `placement=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.predict as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.predict as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.PredictRequest', ['placement']); - request.placement = defaultValue1; - const expectedHeaderRequestParams = `placement=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.predict as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.predict as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.PredictRequest', ['placement']); - request.placement = defaultValue1; - const expectedHeaderRequestParams = `placement=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.predict = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.predict(request), expectedError); - const actualRequest = (client.innerApiCalls.predict as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.predict as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.PredictRequest', ['placement']); - request.placement = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.predict(request), expectedError); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('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('merchantCenterAccountLink', () => { - const fakePath = "/rendered/path/merchantCenterAccountLink"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - merchant_center_account_link: "merchantCenterAccountLinkValue", - }; - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.merchantCenterAccountLinkPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.merchantCenterAccountLinkPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('merchantCenterAccountLinkPath', () => { - const result = client.merchantCenterAccountLinkPath("projectValue", "locationValue", "catalogValue", "merchantCenterAccountLinkValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromMerchantCenterAccountLinkName', () => { - const result = client.matchProjectFromMerchantCenterAccountLinkName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromMerchantCenterAccountLinkName', () => { - const result = client.matchLocationFromMerchantCenterAccountLinkName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromMerchantCenterAccountLinkName', () => { - const result = client.matchCatalogFromMerchantCenterAccountLinkName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName', () => { - const result = client.matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName(fakePath); - assert.strictEqual(result, "merchantCenterAccountLinkValue"); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('model', () => { - const fakePath = "/rendered/path/model"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - model: "modelValue", - }; - const client = new predictionserviceModule.v2alpha.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.modelPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.modelPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('modelPath', () => { - const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.modelPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromModelName', () => { - const result = client.matchProjectFromModelName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromModelName', () => { - const result = client.matchLocationFromModelName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromModelName', () => { - const result = client.matchCatalogFromModelName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchModelFromModelName', () => { - const result = client.matchModelFromModelName(fakePath); - assert.strictEqual(result, "modelValue"); - assert((client.pathTemplates.modelPathTemplate.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/google-cloud-retail/v2alpha/test/gapic_product_service_v2alpha.ts b/owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_product_service_v2alpha.ts deleted file mode 100644 index ffcd6f348ce..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_product_service_v2alpha.ts +++ /dev/null @@ -1,2870 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This 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, LocationProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v2alpha.ProductServiceClient', () => { - describe('Common methods', () => { - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.CreateProductRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProduct without error using callback', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.CreateProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.CreateProductRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProduct with error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.CreateProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.CreateProductRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createProduct(request), expectedError); - const actualRequest = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProduct with closed client', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.CreateProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.CreateProductRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createProduct(request), expectedError); - }); - }); - - describe('getProduct', () => { - it('invokes getProduct without error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.GetProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.GetProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProduct without error using callback', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.GetProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.GetProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProduct with error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.GetProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.GetProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getProduct(request), expectedError); - const actualRequest = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProduct with closed client', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.GetProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.GetProductRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getProduct(request), expectedError); - }); - }); - - describe('updateProduct', () => { - it('invokes updateProduct without error', async () => { - const client = new 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateProductRequest', ['product', 'name']); - request.product.name = defaultValue1; - const expectedHeaderRequestParams = `product.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProduct without error using callback', async () => { - const client = new 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateProductRequest', ['product', 'name']); - request.product.name = defaultValue1; - const expectedHeaderRequestParams = `product.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProduct with error', async () => { - const client = new 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateProductRequest', ['product', 'name']); - request.product.name = defaultValue1; - const expectedHeaderRequestParams = `product.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateProduct(request), expectedError); - const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProduct with closed client', async () => { - const client = new 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateProductRequest', ['product', 'name']); - request.product.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateProduct(request), expectedError); - }); - }); - - describe('deleteProduct', () => { - it('invokes deleteProduct without error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.DeleteProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.DeleteProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteProduct = stubSimpleCall(expectedResponse); - const [response] = await client.deleteProduct(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProduct without error using callback', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.DeleteProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.DeleteProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteProduct( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProduct with error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.DeleteProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.DeleteProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteProduct(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProduct with closed client', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.DeleteProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.DeleteProductRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteProduct(request), expectedError); - }); - }); - - describe('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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.PurgeProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.purgeProducts = stubLongRunningCall(expectedResponse); - const [operation] = await client.purgeProducts(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes purgeProducts without error using callback', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.PurgeProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.PurgeProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.purgeProducts = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.purgeProducts( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes purgeProducts with call error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.PurgeProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.PurgeProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.purgeProducts = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.purgeProducts(request), expectedError); - const actualRequest = (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes purgeProducts with LRO error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.PurgeProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.PurgeProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.purgeProducts = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.purgeProducts(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkPurgeProductsProgress without error', async () => { - const client = new 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ImportProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.importProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ImportProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.importProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ImportProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importProducts = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importProducts(request), expectedError); - const actualRequest = (client.innerApiCalls.importProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ImportProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importProducts = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importProducts(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.importProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.SetInventoryRequest', ['inventory', 'name']); - request.inventory.name = defaultValue1; - const expectedHeaderRequestParams = `inventory.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.setInventory as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInventory as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.SetInventoryRequest', ['inventory', 'name']); - request.inventory.name = defaultValue1; - const expectedHeaderRequestParams = `inventory.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.setInventory as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInventory as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.SetInventoryRequest', ['inventory', 'name']); - request.inventory.name = defaultValue1; - const expectedHeaderRequestParams = `inventory.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.setInventory = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.setInventory(request), expectedError); - const actualRequest = (client.innerApiCalls.setInventory as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInventory as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.SetInventoryRequest', ['inventory', 'name']); - request.inventory.name = defaultValue1; - const expectedHeaderRequestParams = `inventory.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.setInventory = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.setInventory(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.setInventory as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInventory as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.addFulfillmentPlaces(request), expectedError); - const actualRequest = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.AddFulfillmentPlacesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.addFulfillmentPlaces(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.removeFulfillmentPlaces(request), expectedError); - const actualRequest = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.RemoveFulfillmentPlacesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.removeFulfillmentPlaces(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.AddLocalInventoriesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.addLocalInventories as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addLocalInventories as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.AddLocalInventoriesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.addLocalInventories as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addLocalInventories as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.AddLocalInventoriesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.addLocalInventories = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.addLocalInventories(request), expectedError); - const actualRequest = (client.innerApiCalls.addLocalInventories as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addLocalInventories as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.AddLocalInventoriesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.addLocalInventories = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.addLocalInventories(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.addLocalInventories as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addLocalInventories as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.removeLocalInventories as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeLocalInventories as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.removeLocalInventories as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeLocalInventories as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.removeLocalInventories = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.removeLocalInventories(request), expectedError); - const actualRequest = (client.innerApiCalls.removeLocalInventories as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeLocalInventories as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.RemoveLocalInventoriesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.removeLocalInventories = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.removeLocalInventories(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.removeLocalInventories as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeLocalInventories as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProducts without error using callback', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProducts with error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listProducts = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProducts(request), expectedError); - const actualRequest = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductsStream without error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listProductsStream with error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProducts.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProductsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.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( - (client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProducts without error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProducts with error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2alpha.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProductsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.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( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('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('merchantCenterAccountLink', () => { - const fakePath = "/rendered/path/merchantCenterAccountLink"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - merchant_center_account_link: "merchantCenterAccountLinkValue", - }; - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.merchantCenterAccountLinkPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.merchantCenterAccountLinkPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('merchantCenterAccountLinkPath', () => { - const result = client.merchantCenterAccountLinkPath("projectValue", "locationValue", "catalogValue", "merchantCenterAccountLinkValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromMerchantCenterAccountLinkName', () => { - const result = client.matchProjectFromMerchantCenterAccountLinkName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromMerchantCenterAccountLinkName', () => { - const result = client.matchLocationFromMerchantCenterAccountLinkName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromMerchantCenterAccountLinkName', () => { - const result = client.matchCatalogFromMerchantCenterAccountLinkName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName', () => { - const result = client.matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName(fakePath); - assert.strictEqual(result, "merchantCenterAccountLinkValue"); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('model', () => { - const fakePath = "/rendered/path/model"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - model: "modelValue", - }; - const client = new productserviceModule.v2alpha.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.modelPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.modelPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('modelPath', () => { - const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.modelPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromModelName', () => { - const result = client.matchProjectFromModelName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromModelName', () => { - const result = client.matchLocationFromModelName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromModelName', () => { - const result = client.matchCatalogFromModelName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchModelFromModelName', () => { - const result = client.matchModelFromModelName(fakePath); - assert.strictEqual(result, "modelValue"); - assert((client.pathTemplates.modelPathTemplate.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/google-cloud-retail/v2alpha/test/gapic_search_service_v2alpha.ts b/owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_search_service_v2alpha.ts deleted file mode 100644 index 2499cbc9da5..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_search_service_v2alpha.ts +++ /dev/null @@ -1,1390 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This 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, operationsProtos, LocationProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function 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', () => { - describe('Common methods', () => { - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.SearchRequest', ['placement']); - request.placement = defaultValue1; - const expectedHeaderRequestParams = `placement=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.search as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.search as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.SearchRequest', ['placement']); - request.placement = defaultValue1; - const expectedHeaderRequestParams = `placement=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.search as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.search as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.SearchRequest', ['placement']); - request.placement = defaultValue1; - const expectedHeaderRequestParams = `placement=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.search = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.search(request), expectedError); - const actualRequest = (client.innerApiCalls.search as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.search as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.SearchRequest', ['placement']); - request.placement = defaultValue1; - const expectedHeaderRequestParams = `placement=${defaultValue1}`; - 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( - (client.descriptors.page.search.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.SearchRequest', ['placement']); - request.placement = defaultValue1; - const expectedHeaderRequestParams = `placement=${defaultValue1}`; - 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( - (client.descriptors.page.search.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.SearchRequest', ['placement']); - request.placement = defaultValue1; - const expectedHeaderRequestParams = `placement=${defaultValue1}`; - 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( - (client.descriptors.page.search.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.SearchRequest', ['placement']); - request.placement = defaultValue1; - const expectedHeaderRequestParams = `placement=${defaultValue1}`; - 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( - (client.descriptors.page.search.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('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('experiment', () => { - const fakePath = "/rendered/path/experiment"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - experiment: "experimentValue", - }; - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.experimentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.experimentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('experimentPath', () => { - const result = client.experimentPath("projectValue", "locationValue", "catalogValue", "experimentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.experimentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromExperimentName', () => { - const result = client.matchProjectFromExperimentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.experimentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromExperimentName', () => { - const result = client.matchLocationFromExperimentName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.experimentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromExperimentName', () => { - const result = client.matchCatalogFromExperimentName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.experimentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchExperimentFromExperimentName', () => { - const result = client.matchExperimentFromExperimentName(fakePath); - assert.strictEqual(result, "experimentValue"); - assert((client.pathTemplates.experimentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('merchantCenterAccountLink', () => { - const fakePath = "/rendered/path/merchantCenterAccountLink"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - merchant_center_account_link: "merchantCenterAccountLinkValue", - }; - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.merchantCenterAccountLinkPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.merchantCenterAccountLinkPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('merchantCenterAccountLinkPath', () => { - const result = client.merchantCenterAccountLinkPath("projectValue", "locationValue", "catalogValue", "merchantCenterAccountLinkValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromMerchantCenterAccountLinkName', () => { - const result = client.matchProjectFromMerchantCenterAccountLinkName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromMerchantCenterAccountLinkName', () => { - const result = client.matchLocationFromMerchantCenterAccountLinkName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromMerchantCenterAccountLinkName', () => { - const result = client.matchCatalogFromMerchantCenterAccountLinkName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName', () => { - const result = client.matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName(fakePath); - assert.strictEqual(result, "merchantCenterAccountLinkValue"); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('model', () => { - const fakePath = "/rendered/path/model"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - model: "modelValue", - }; - const client = new searchserviceModule.v2alpha.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.modelPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.modelPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('modelPath', () => { - const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.modelPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromModelName', () => { - const result = client.matchProjectFromModelName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromModelName', () => { - const result = client.matchLocationFromModelName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromModelName', () => { - const result = client.matchCatalogFromModelName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchModelFromModelName', () => { - const result = client.matchModelFromModelName(fakePath); - assert.strictEqual(result, "modelValue"); - assert((client.pathTemplates.modelPathTemplate.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/google-cloud-retail/v2alpha/test/gapic_serving_config_service_v2alpha.ts b/owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_serving_config_service_v2alpha.ts deleted file mode 100644 index 6c336584cf5..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_serving_config_service_v2alpha.ts +++ /dev/null @@ -1,1934 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This 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, operationsProtos, LocationProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function 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', () => { - describe('Common methods', () => { - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.CreateServingConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.createServingConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createServingConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.CreateServingConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.createServingConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createServingConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.CreateServingConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createServingConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createServingConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.createServingConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createServingConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.CreateServingConfigRequest', ['parent']); - request.parent = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.DeleteServingConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteServingConfig = stubSimpleCall(expectedResponse); - const [response] = await client.deleteServingConfig(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteServingConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteServingConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.DeleteServingConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.deleteServingConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteServingConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.DeleteServingConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteServingConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteServingConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteServingConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteServingConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.DeleteServingConfigRequest', ['name']); - request.name = defaultValue1; - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateServingConfigRequest', ['servingConfig', 'name']); - request.servingConfig.name = defaultValue1; - const expectedHeaderRequestParams = `serving_config.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.updateServingConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateServingConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateServingConfigRequest', ['servingConfig', 'name']); - request.servingConfig.name = defaultValue1; - const expectedHeaderRequestParams = `serving_config.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.updateServingConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateServingConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateServingConfigRequest', ['servingConfig', 'name']); - request.servingConfig.name = defaultValue1; - const expectedHeaderRequestParams = `serving_config.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateServingConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateServingConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.updateServingConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateServingConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.UpdateServingConfigRequest', ['servingConfig', 'name']); - request.servingConfig.name = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.GetServingConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getServingConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getServingConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.GetServingConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getServingConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getServingConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.GetServingConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getServingConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getServingConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.getServingConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getServingConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.GetServingConfigRequest', ['name']); - request.name = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.AddControlRequest', ['servingConfig']); - request.servingConfig = defaultValue1; - const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.addControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.AddControlRequest', ['servingConfig']); - request.servingConfig = defaultValue1; - const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.addControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.AddControlRequest', ['servingConfig']); - request.servingConfig = defaultValue1; - const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.addControl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.addControl(request), expectedError); - const actualRequest = (client.innerApiCalls.addControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.AddControlRequest', ['servingConfig']); - request.servingConfig = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.RemoveControlRequest', ['servingConfig']); - request.servingConfig = defaultValue1; - const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.removeControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.RemoveControlRequest', ['servingConfig']); - request.servingConfig = defaultValue1; - const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.removeControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.RemoveControlRequest', ['servingConfig']); - request.servingConfig = defaultValue1; - const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.removeControl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.removeControl(request), expectedError); - const actualRequest = (client.innerApiCalls.removeControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.RemoveControlRequest', ['servingConfig']); - request.servingConfig = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ListServingConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.listServingConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServingConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ListServingConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.listServingConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServingConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ListServingConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listServingConfigs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listServingConfigs(request), expectedError); - const actualRequest = (client.innerApiCalls.listServingConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServingConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ListServingConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listServingConfigs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ListServingConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listServingConfigs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ListServingConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ListServingConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('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('merchantCenterAccountLink', () => { - const fakePath = "/rendered/path/merchantCenterAccountLink"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - merchant_center_account_link: "merchantCenterAccountLinkValue", - }; - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.merchantCenterAccountLinkPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.merchantCenterAccountLinkPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('merchantCenterAccountLinkPath', () => { - const result = client.merchantCenterAccountLinkPath("projectValue", "locationValue", "catalogValue", "merchantCenterAccountLinkValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromMerchantCenterAccountLinkName', () => { - const result = client.matchProjectFromMerchantCenterAccountLinkName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromMerchantCenterAccountLinkName', () => { - const result = client.matchLocationFromMerchantCenterAccountLinkName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromMerchantCenterAccountLinkName', () => { - const result = client.matchCatalogFromMerchantCenterAccountLinkName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName', () => { - const result = client.matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName(fakePath); - assert.strictEqual(result, "merchantCenterAccountLinkValue"); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('model', () => { - const fakePath = "/rendered/path/model"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - model: "modelValue", - }; - const client = new servingconfigserviceModule.v2alpha.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.modelPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.modelPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('modelPath', () => { - const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.modelPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromModelName', () => { - const result = client.matchProjectFromModelName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromModelName', () => { - const result = client.matchLocationFromModelName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromModelName', () => { - const result = client.matchCatalogFromModelName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchModelFromModelName', () => { - const result = client.matchModelFromModelName(fakePath); - assert.strictEqual(result, "modelValue"); - assert((client.pathTemplates.modelPathTemplate.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/google-cloud-retail/v2alpha/test/gapic_user_event_service_v2alpha.ts b/owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_user_event_service_v2alpha.ts deleted file mode 100644 index 85baa7f10d7..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2alpha/test/gapic_user_event_service_v2alpha.ts +++ /dev/null @@ -1,1704 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This 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, LocationProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function 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.UserEventServiceClient', () => { - describe('Common methods', () => { - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.WriteUserEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.WriteUserEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.WriteUserEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.writeUserEvent = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.writeUserEvent(request), expectedError); - const actualRequest = (client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.WriteUserEventRequest', ['parent']); - request.parent = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.CollectUserEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.api.HttpBody() - ); - client.innerApiCalls.collectUserEvent = stubSimpleCall(expectedResponse); - const [response] = await client.collectUserEvent(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.CollectUserEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.CollectUserEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.collectUserEvent = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.collectUserEvent(request), expectedError); - const actualRequest = (client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.CollectUserEventRequest', ['parent']); - request.parent = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.PurgeUserEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.purgeUserEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeUserEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.PurgeUserEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.purgeUserEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeUserEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.PurgeUserEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.purgeUserEvents = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.purgeUserEvents(request), expectedError); - const actualRequest = (client.innerApiCalls.purgeUserEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeUserEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.PurgeUserEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.purgeUserEvents = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.purgeUserEvents(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.purgeUserEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeUserEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ImportUserEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ImportUserEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ImportUserEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importUserEvents = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importUserEvents(request), expectedError); - const actualRequest = (client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.ImportUserEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importUserEvents = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importUserEvents(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.RejoinUserEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.rejoinUserEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rejoinUserEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.RejoinUserEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.rejoinUserEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rejoinUserEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.RejoinUserEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.rejoinUserEvents(request), expectedError); - const actualRequest = (client.innerApiCalls.rejoinUserEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rejoinUserEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2alpha.RejoinUserEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.rejoinUserEvents(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.rejoinUserEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rejoinUserEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('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('merchantCenterAccountLink', () => { - const fakePath = "/rendered/path/merchantCenterAccountLink"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - merchant_center_account_link: "merchantCenterAccountLinkValue", - }; - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.merchantCenterAccountLinkPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.merchantCenterAccountLinkPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('merchantCenterAccountLinkPath', () => { - const result = client.merchantCenterAccountLinkPath("projectValue", "locationValue", "catalogValue", "merchantCenterAccountLinkValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromMerchantCenterAccountLinkName', () => { - const result = client.matchProjectFromMerchantCenterAccountLinkName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromMerchantCenterAccountLinkName', () => { - const result = client.matchLocationFromMerchantCenterAccountLinkName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromMerchantCenterAccountLinkName', () => { - const result = client.matchCatalogFromMerchantCenterAccountLinkName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName', () => { - const result = client.matchMerchantCenterAccountLinkFromMerchantCenterAccountLinkName(fakePath); - assert.strictEqual(result, "merchantCenterAccountLinkValue"); - assert((client.pathTemplates.merchantCenterAccountLinkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('model', () => { - const fakePath = "/rendered/path/model"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - model: "modelValue", - }; - const client = new usereventserviceModule.v2alpha.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.modelPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.modelPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('modelPath', () => { - const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.modelPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromModelName', () => { - const result = client.matchProjectFromModelName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromModelName', () => { - const result = client.matchLocationFromModelName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromModelName', () => { - const result = client.matchCatalogFromModelName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchModelFromModelName', () => { - const result = client.matchModelFromModelName(fakePath); - assert.strictEqual(result, "modelValue"); - assert((client.pathTemplates.modelPathTemplate.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/google-cloud-retail/v2alpha/tsconfig.json b/owl-bot-staging/google-cloud-retail/v2alpha/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2alpha/webpack.config.js b/owl-bot-staging/google-cloud-retail/v2alpha/webpack.config.js deleted file mode 100644 index f2c58f2530c..00000000000 --- a/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2beta/.eslintignore b/owl-bot-staging/google-cloud-retail/v2beta/.eslintignore deleted file mode 100644 index cfc348ec4d1..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/google-cloud-retail/v2beta/.eslintrc.json b/owl-bot-staging/google-cloud-retail/v2beta/.eslintrc.json deleted file mode 100644 index 78215349546..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/google-cloud-retail/v2beta/.gitignore b/owl-bot-staging/google-cloud-retail/v2beta/.gitignore deleted file mode 100644 index d4f03a0df2e..00000000000 --- a/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2beta/.jsdoc.js b/owl-bot-staging/google-cloud-retail/v2beta/.jsdoc.js deleted file mode 100644 index 66e9db869e8..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/.jsdoc.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file 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 2023 Google LLC', - includeDate: false, - sourceFiles: false, - systemName: '@google-cloud/retail', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/google-cloud-retail/v2beta/.mocharc.js b/owl-bot-staging/google-cloud-retail/v2beta/.mocharc.js deleted file mode 100644 index 1a38f257db7..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/.mocharc.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -const config = { - "enable-source-maps": true, - "throw-deprecation": true, - "timeout": 10000 -} -if (process.env.MOCHA_THROW_DEPRECATION === 'false') { - delete config['throw-deprecation']; -} -if (process.env.MOCHA_REPORTER) { - config.reporter = process.env.MOCHA_REPORTER; -} -if (process.env.MOCHA_REPORTER_OUTPUT) { - config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; -} -module.exports = config diff --git a/owl-bot-staging/google-cloud-retail/v2beta/.prettierrc.js b/owl-bot-staging/google-cloud-retail/v2beta/.prettierrc.js deleted file mode 100644 index 55639e70f9e..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/.prettierrc.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -module.exports = { - ...require('gts/.prettierrc.json') -} diff --git a/owl-bot-staging/google-cloud-retail/v2beta/README.md b/owl-bot-staging/google-cloud-retail/v2beta/README.md deleted file mode 100644 index 822c4573817..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/README.md +++ /dev/null @@ -1 +0,0 @@ -Retail: Nodejs Client diff --git a/owl-bot-staging/google-cloud-retail/v2beta/linkinator.config.json b/owl-bot-staging/google-cloud-retail/v2beta/linkinator.config.json deleted file mode 100644 index befd23c8633..00000000000 --- a/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2beta/package.json b/owl-bot-staging/google-cloud-retail/v2beta/package.json deleted file mode 100644 index 468da5696b6..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/package.json +++ /dev/null @@ -1,72 +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", - "model service", - "prediction service", - "product service", - "search service", - "serving config service", - "user event service" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/ && minifyProtoJson", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^3.5.7" - }, - "devDependencies": { - "@types/mocha": "^10.0.1", - "@types/node": "^18.11.18", - "@types/sinon": "^10.0.13", - "c8": "^7.12.0", - "gts": "^3.1.1", - "jsdoc": "^4.0.0", - "jsdoc-fresh": "^2.0.1", - "jsdoc-region-tag": "^2.0.1", - "linkinator": "^4.1.2", - "mocha": "^10.2.0", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^15.0.1", - "ts-loader": "^8.4.0", - "typescript": "^4.8.4", - "webpack": "^4.46.0", - "webpack-cli": "^4.10.0" - }, - "engines": { - "node": ">=v12" - } -} diff --git a/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/catalog.proto b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/catalog.proto deleted file mode 100644 index 83e6d10cd45..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/catalog.proto +++ /dev/null @@ -1,476 +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 = "cloud.google.com/go/retail/apiv2beta/retailpb;retailpb"; -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` (incompatible with Retail Search): 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 [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.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 [Product - // levels](https://cloud.google.com/retail/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. - 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. - 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. - SEARCHABLE_OPTION_UNSPECIFIED = 0; - - // Searchable option enabled for an attribute. - SEARCHABLE_ENABLED = 1; - - // Searchable option disabled for an attribute. - SEARCHABLE_DISABLED = 2; - } - - // The status of the exact-searchable option of a catalog attribute. - enum ExactSearchableOption { - // Value used when unset. - EXACT_SEARCHABLE_OPTION_UNSPECIFIED = 0; - - // Exact searchable option enabled for an attribute. - EXACT_SEARCHABLE_ENABLED = 1; - - // Exact searchable option disabled for an attribute. - EXACT_SEARCHABLE_DISABLED = 2; - } - - // The status of the retrievable option of a catalog attribute. - enum RetrievableOption { - // Value used when unset. - RETRIEVABLE_OPTION_UNSPECIFIED = 0; - - // Retrievable option enabled for an attribute. - RETRIEVABLE_ENABLED = 1; - - // Retrievable option disabled for an attribute. - RETRIEVABLE_DISABLED = 2; - } - - // Required. Attribute name. - // For example: `color`, `brands`, `attributes.custom_attribute`, such as - // `attributes.xyz`. - // To be indexable, the attribute name can contain only alpha-numeric - // characters and underscores. For example, an attribute named - // `attributes.abc_xyz` can be indexed, but an attribute named - // `attributes.abc-xyz` cannot be indexed. - // - // If the attribute key starts with `attributes.`, then the attribute is a - // custom attribute. Attributes such as `brands`, `patterns`, and `title` are - // built-in and called system attributes. - 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 - // [CatalogService.AddCatalogAttribute][google.cloud.retail.v2beta.CatalogService.AddCatalogAttribute], - // [CatalogService.ImportCatalogAttributes][], or - // [CatalogService.UpdateAttributesConfig][google.cloud.retail.v2beta.CatalogService.UpdateAttributesConfig] - // APIs. This field is `False` for pre-loaded - // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute]s. - // - // Only pre-loaded [catalog - // attributes][google.cloud.retail.v2beta.CatalogAttribute] that are neither - // in use by products nor predefined can be deleted. [Catalog - // attributes][google.cloud.retail.v2beta.CatalogAttribute] that are - // either in use by products or are predefined attributes 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]. - // - // Must be specified, otherwise throws INVALID_FORMAT error. - 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. - // - // Must be specified, otherwise throws INVALID_FORMAT error. - 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. - // - // Must be specified, otherwise throws INVALID_FORMAT error. - SearchableOption searchable_option = 7; - - // When - // [AttributesConfig.attribute_config_level][google.cloud.retail.v2beta.AttributesConfig.attribute_config_level] - // is CATALOG_LEVEL_ATTRIBUTE_CONFIG, if RECOMMENDATIONS_FILTERING_ENABLED, - // attribute values are filterable for recommendations. - // This option works for categorical features only, - // does not work for numerical features, inventory filtering. - RecommendationsFilteringOption recommendations_filtering_option = 8; - - // If EXACT_SEARCHABLE_ENABLED, attribute values will be exact searchable. - // This property only applies to textual custom attributes and requires - // indexable set to enabled to enable exact-searchable. If unset, the server - // behavior defaults to - // [EXACT_SEARCHABLE_DISABLED][google.cloud.retail.v2beta.CatalogAttribute.ExactSearchableOption.EXACT_SEARCHABLE_DISABLED]. - ExactSearchableOption exact_searchable_option = 11; - - // If RETRIEVABLE_ENABLED, attribute values are retrievable in the search - // results. If unset, the server behavior defaults to - // [RETRIEVABLE_DISABLED][google.cloud.retail.v2beta.CatalogAttribute.RetrievableOption.RETRIEVABLE_DISABLED]. - RetrievableOption retrievable_option = 12; -} - -// 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. Default - // value is 20. If left unset or set to 0, then will fallback to default - // value. - // - // Value range is 1 to 20. - 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. - // - // Value range is 1 to 20. - 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 source data for the latest import of the autocomplete - // suggestion phrases. - 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 source data for the latest import of the autocomplete - // denylist phrases. - CompletionDataInputConfig denylist_input_config = 7 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Name of the 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 source data for the latest import of the autocomplete - // allowlist phrases. - CompletionDataInputConfig allowlist_input_config = 9 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Name of the 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 is given in [Included - // destination](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; - - // Criteria for the Merchant Center feeds to be ingested via the link. - // All offers will be ingested if the list is empty. - // Otherwise the offers will be ingested from selected feeds. - repeated MerchantCenterFeedFilter feeds = 6; -} - -// Merchant Center Feed filter criterion. -message MerchantCenterFeedFilter { - // Merchant Center primary feed ID. - int64 primary_feed_id = 1; - - // Merchant Center primary feed name. The name is used for the display - // purposes only. - string primary_feed_name = 2; -} - -// 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/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/catalog_service.proto b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/catalog_service.proto deleted file mode 100644 index 337111764f1..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/catalog_service.proto +++ /dev/null @@ -1,527 +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 = "cloud.google.com/go/retail/apiv2beta/retailpb;retailpb"; -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: "*" - }; - } - - // Removes all specified - // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute]s from the - // [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig]. - rpc BatchRemoveCatalogAttributes(BatchRemoveCatalogAttributesRequest) - returns (BatchRemoveCatalogAttributesResponse) { - option (google.api.http) = { - post: "/v2beta/{attributes_config=projects/*/locations/*/catalogs/*/attributesConfig}:batchRemoveCatalogAttributes" - 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.BatchRemoveCatalogAttributes][google.cloud.retail.v2beta.CatalogService.BatchRemoveCatalogAttributes] -// method. -message BatchRemoveCatalogAttributesRequest { - // Required. The attributes config resource shared by all catalog attributes - // being deleted. 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 keys of the - // [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute]s to delete. - // A maximum of 1000 catalog attributes can be deleted in a batch. - repeated string attribute_keys = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Response of the -// [CatalogService.BatchRemoveCatalogAttributes][google.cloud.retail.v2beta.CatalogService.BatchRemoveCatalogAttributes]. -message BatchRemoveCatalogAttributesResponse { - // Catalog attributes that were deleted. Only pre-loaded [catalog - // attributes][google.cloud.retail.v2beta.CatalogAttribute] that are - // neither [in - // use][google.cloud.retail.v2beta.CatalogAttribute.in_use] by - // products nor predefined can be deleted. - repeated string deleted_catalog_attributes = 1; - - // Catalog attributes that were reset. [Catalog - // attributes][google.cloud.retail.v2beta.CatalogAttribute] that are either - // [in use][google.cloud.retail.v2beta.CatalogAttribute.in_use] by products or - // are predefined attributes cannot be deleted; however, their configuration - // properties will reset to default values upon removal request. - repeated string reset_catalog_attributes = 2; -} - -// 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/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/common.proto b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/common.proto deleted file mode 100644 index 1ffa26902e1..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/common.proto +++ /dev/null @@ -1,793 +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 = "cloud.google.com/go/retail/apiv2beta/retailpb;retailpb"; -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. In this case, server behavior 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; -} - -// If filtering for recommendations is enabled. -enum RecommendationsFilteringOption { - // Value used when unset. - // In this case, server behavior defaults to - // [RECOMMENDATIONS_FILTERING_DISABLED][google.cloud.retail.v2beta.RecommendationsFilteringOption.RECOMMENDATIONS_FILTERING_DISABLED]. - RECOMMENDATIONS_FILTERING_OPTION_UNSPECIFIED = 0; - - // Recommendation filtering is disabled. - RECOMMENDATIONS_FILTERING_DISABLED = 1; - - // Recommendation filtering is enabled. - RECOMMENDATIONS_FILTERING_ENABLED = 3; -} - -// The use case of Cloud Retail Search. -enum SearchSolutionUseCase { - // The value when it's unspecified. In this case, server behavior defaults to - // [SEARCH_SOLUTION_USE_CASE_SEARCH][google.cloud.retail.v2beta.SearchSolutionUseCase.SEARCH_SOLUTION_USE_CASE_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. - // For example, "a b c" is 3 terms and allowed, but " a b c d" is 4 terms - // and not allowed for a 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 rules only work for [controls][google.cloud.retail.v2beta.Control] -// with -// [SOLUTION_TYPE_SEARCH][google.cloud.retail.v2beta.SolutionType.SOLUTION_TYPE_SEARCH]. -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][google.cloud.retail.v2beta.Condition.query_terms] - // provided is a global match. - // - 1 or more - // [Condition.query_terms][google.cloud.retail.v2beta.Condition.query_terms] - // provided are combined with OR operator. - // * Action Input: The request query and filter that are 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][google.cloud.retail.v2beta.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 75 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 is normally ignored unless - // [AttributesConfig.attribute_config_level][google.cloud.retail.v2beta.AttributesConfig.attribute_config_level] - // of the [Catalog][google.cloud.retail.v2beta.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.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 [deprecated = true]; - - // This field is normally ignored unless - // [AttributesConfig.attribute_config_level][google.cloud.retail.v2beta.AttributesConfig.attribute_config_level] - // of the [Catalog][google.cloud.retail.v2beta.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.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 [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.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 not be larger than 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. - // 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]. If set, - // [original_price][google.cloud.retail.v2beta.PriceInfo.original_price] - // should be greater than or equal to - // [price][google.cloud.retail.v2beta.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.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. 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.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/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/completion_service.proto b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/completion_service.proto deleted file mode 100644 index 9442028b908..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/completion_service.proto +++ /dev/null @@ -1,220 +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 = "cloud.google.com/go/retail/apiv2beta/retailpb;retailpb"; -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"; - -// Autocomplete service for retail. -// -// This feature is only available for users who have Retail Search enabled. -// 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. - // 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. - // 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" - }; - } -} - -// Autocomplete 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; - - // Note that this field applies for `user-data` dataset only. For requests - // with `cloud-retail` dataset, setting this field has no effect. - // - // 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. We recommend that you - // leave this field empty. - // - // It can 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 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][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; - - // The entity for customers that may run multiple different entities, domains, - // sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, - // `google.com`, `youtube.com`, etc. - // If this is set, it should be exactly matched with - // [UserEvent.entity][google.cloud.retail.v2beta.UserEvent.entity] to get - // per-entity autocomplete results. - string entity = 10; -} - -// Response of the autocomplete 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. It requires - // [UserEvent.product_details][google.cloud.retail.v2beta.UserEvent.product_details] - // is imported properly. - 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 case. - // - // * 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/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/control.proto b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/control.proto deleted file mode 100644 index e44cfdd672d..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/control.proto +++ /dev/null @@ -1,100 +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 = "cloud.google.com/go/retail/apiv2beta/retailpb;retailpb"; -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 metadata that can be linked to a -// [ServingConfig][google.cloud.retail.v2beta.ServingConfig] and affect search -// or recommendation results at serving time. -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. - // - // Note that this field is deprecated and will throw NOT_IMPLEMENTED if - // used for creating a control. - SearchRequest.FacetSpec facet_spec = 3 [deprecated = true]; - - // 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 - // config][google.cloud.retail.v2beta.ServingConfig] ids that are associated - // with this control in the same - // [Catalog][google.cloud.retail.v2beta.Catalog]. - // - // Note the association is managed via the - // [ServingConfig][google.cloud.retail.v2beta.ServingConfig], this is an - // output only denormalized view. - repeated string associated_serving_config_ids = 5 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Required. Immutable. The solution types that the control 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][google.cloud.retail.v2beta.SolutionType.SOLUTION_TYPE_SEARCH]. - repeated SolutionType solution_types = 6 [ - (google.api.field_behavior) = REQUIRED, - (google.api.field_behavior) = IMMUTABLE - ]; - - // 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][google.cloud.retail.v2beta.SearchSolutionUseCase.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; -} diff --git a/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/control_service.proto b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/control_service.proto deleted file mode 100644 index 6a9a8707fb2..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/control_service.proto +++ /dev/null @@ -1,185 +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 = "cloud.google.com/go/retail/apiv2beta/retailpb;retailpb"; -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 update 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 by their parent - // [Catalog][google.cloud.retail.v2beta.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 get. 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/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/export_config.proto b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/export_config.proto deleted file mode 100644 index 9efc0d195a6..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/export_config.proto +++ /dev/null @@ -1,107 +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 = "cloud.google.com/go/retail/apiv2beta/retailpb;retailpb"; -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 is -// 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; - - // This field is never set. - ExportErrorsConfig errors_config = 2; - - // Output result indicating where the data were exported to. - OutputResult output_result = 3; -} - -// 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; - - // This field is never set. - ExportErrorsConfig errors_config = 2; - - // Output result indicating where the data were exported to. - OutputResult output_result = 3; -} - -// Output result that stores the information about where the exported data is -// stored. -message OutputResult { - // The BigQuery location where the result is stored. - repeated BigQueryOutputResult bigquery_result = 1; - - // The Google Cloud Storage location where the result is stored. - repeated GcsOutputResult gcs_result = 2; -} - -// A BigQuery output result. -message BigQueryOutputResult { - // The ID of a BigQuery Dataset. - string dataset_id = 1; - - // The ID of a BigQuery Table. - string table_id = 2; -} - -// A Gcs output result. -message GcsOutputResult { - // The uri of Gcs output - string output_uri = 1; -} diff --git a/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/import_config.proto b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/import_config.proto deleted file mode 100644 index ad58554e650..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/import_config.proto +++ /dev/null @@ -1,386 +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 = "cloud.google.com/go/retail/apiv2beta/retailpb;retailpb"; -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. -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 in - // [ImportProductsRequest][google.cloud.retail.v2beta.ImportProductsRequest]. - 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`: - // The schema is available here: - // https://support.google.com/analytics/answer/7029846. - // - // Supported values for autocomplete 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 are 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. - 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, all fields are updated. - 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; - - // Full Pub/Sub topic name for receiving notification. If this field is set, - // when the import is finished, a notification is sent to - // specified Pub/Sub topic. The message data is 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.v2beta.ImportProductsRequest.parent]. - // Make sure that `service-@gcp-sa-retail.iam.gserviceaccount.com` has the - // `pubsub.topics.publish` IAM permission on the topic. - 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 is sent to - // specified Pub/Sub topic. The message data is 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 is -// 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 is sent to - // specified Pub/Sub topic. The message data is 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/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/model.proto b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/model.proto deleted file mode 100644 index 92a3a43d5ea..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/model.proto +++ /dev/null @@ -1,239 +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/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Beta"; -option go_package = "cloud.google.com/go/retail/apiv2beta/retailpb;retailpb"; -option java_multiple_files = true; -option java_outer_classname = "ModelProto"; -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 that describes the training and serving parameters of a -// [Model][google.cloud.retail.v2beta.Model]. A -// [Model][google.cloud.retail.v2beta.Model] can be associated with a -// [ServingConfig][google.cloud.retail.v2beta.ServingConfig] and then queried -// through the Predict API. -message Model { - option (google.api.resource) = { - type: "retail.googleapis.com/Model" - pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}" - }; - - // Represents an ordered combination of valid serving configs, which - // can be used for `PAGE_OPTIMIZATION` recommendations. - message ServingConfigList { - // Optional. A set of valid serving configs that may be used for - // `PAGE_OPTIMIZATION`. - repeated string serving_config_ids = 1 - [(google.api.field_behavior) = OPTIONAL]; - } - - // The serving state of the model. - enum ServingState { - // Unspecified serving state. - SERVING_STATE_UNSPECIFIED = 0; - - // The model is not serving. - INACTIVE = 1; - - // The model is serving and can be queried. - ACTIVE = 2; - - // The model is trained on tuned hyperparameters and can be - // queried. - TUNED = 3; - } - - // The training state of the model. - enum TrainingState { - // Unspecified training state. - TRAINING_STATE_UNSPECIFIED = 0; - - // The model training is paused. - PAUSED = 1; - - // The model is training. - TRAINING = 2; - } - - // Describes whether periodic tuning is enabled for this model - // or not. Periodic tuning is scheduled at most every three months. You can - // start a tuning process manually by using the `TuneModel` - // method, which starts a tuning process immediately and resets the quarterly - // schedule. Enabling or disabling periodic tuning does not affect any - // current tuning processes. - enum PeriodicTuningState { - // Unspecified default value, should never be explicitly set. - PERIODIC_TUNING_STATE_UNSPECIFIED = 0; - - // The model has periodic tuning disabled. Tuning - // can be reenabled by calling the `EnableModelPeriodicTuning` - // method or by calling the `TuneModel` method. - PERIODIC_TUNING_DISABLED = 1; - - // The model cannot be tuned with periodic tuning OR the - // `TuneModel` method. Hide the options in customer UI and - // reject any requests through the backend self serve API. - ALL_TUNING_DISABLED = 3; - - // The model has periodic tuning enabled. Tuning - // can be disabled by calling the `DisableModelPeriodicTuning` - // method. - PERIODIC_TUNING_ENABLED = 2; - } - - // Describes whether this model have sufficient training data - // to be continuously trained. - enum DataState { - // Unspecified default value, should never be explicitly set. - DATA_STATE_UNSPECIFIED = 0; - - // The model has sufficient training data. - DATA_OK = 1; - - // The model does not have sufficient training data. Error - // messages can be queried via Stackdriver. - DATA_ERROR = 2; - } - - // Required. The fully qualified resource name of the model. - // - // Format: - // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` - // catalog_id has char limit of 50. - // recommendation_model_id has char limit of 40. - string name = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The display name of the model. - // - // Should be human readable, used to display Recommendation Models in the - // Retail Cloud Console Dashboard. UTF-8 encoded string with limit of 1024 - // characters. - string display_name = 2 [(google.api.field_behavior) = REQUIRED]; - - // Optional. The training state that the model is in (e.g. - // `TRAINING` or `PAUSED`). - // - // Since part of the cost of running the service - // is frequency of training - this can be used to determine when to train - // model in order to control cost. If not specified: the default value for - // `CreateModel` method is `TRAINING`. The default value for - // `UpdateModel` method is to keep the state the same as before. - TrainingState training_state = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Output only. The serving state of the model: `ACTIVE`, `NOT_ACTIVE`. - ServingState serving_state = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Timestamp the Recommendation Model was created at. - google.protobuf.Timestamp create_time = 5 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. Timestamp the Recommendation Model was last updated. E.g. - // if a Recommendation Model was paused - this would be the time the pause was - // initiated. - google.protobuf.Timestamp update_time = 6 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Required. The type of model e.g. `home-page`. - // - // Currently supported values: `recommended-for-you`, `others-you-may-like`, - // `frequently-bought-together`, `page-optimization`, `similar-items`, - // `buy-it-again`, `on-sale-items`, and `recently-viewed`(readonly value). - // - // - // This field together with - // [optimization_objective][google.cloud.retail.v2beta.Model.optimization_objective] - // describe model metadata to use to control model training and serving. - // See https://cloud.google.com/retail/docs/models - // for more details on what the model metadata control and which combination - // of parameters are valid. For invalid combinations of parameters (e.g. type - // = `frequently-bought-together` and optimization_objective = `ctr`), you - // receive an error 400 if you try to create/update a recommendation with - // this set of knobs. - string type = 7 [(google.api.field_behavior) = REQUIRED]; - - // Optional. The optimization objective e.g. `cvr`. - // - // Currently supported - // values: `ctr`, `cvr`, `revenue-per-order`. - // - // If not specified, we choose default based on model type. - // Default depends on type of recommendation: - // - // `recommended-for-you` => `ctr` - // - // `others-you-may-like` => `ctr` - // - // `frequently-bought-together` => `revenue_per_order` - // - // This field together with - // [optimization_objective][google.cloud.retail.v2beta.Model.type] - // describe model metadata to use to control model training and serving. - // See https://cloud.google.com/retail/docs/models - // for more details on what the model metadata control and which combination - // of parameters are valid. For invalid combinations of parameters (e.g. type - // = `frequently-bought-together` and optimization_objective = `ctr`), you - // receive an error 400 if you try to create/update a recommendation with - // this set of knobs. - string optimization_objective = 8 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The state of periodic tuning. - // - // The period we use is 3 months - to do a - // one-off tune earlier use the `TuneModel` method. Default value - // is `PERIODIC_TUNING_ENABLED`. - PeriodicTuningState periodic_tuning_state = 11 - [(google.api.field_behavior) = OPTIONAL]; - - // Output only. The timestamp when the latest successful tune finished. - google.protobuf.Timestamp last_tune_time = 12 - [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The tune operation associated with the model. - // - // Can be used to determine if there is an ongoing tune for this - // recommendation. Empty field implies no tune is goig on. - string tuning_operation = 15 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Output only. The state of data requirements for this model: `DATA_OK` and - // `DATA_ERROR`. - // - // Recommendation model cannot be trained if the data is in - // `DATA_ERROR` state. Recommendation model can have `DATA_ERROR` state even - // if serving state is `ACTIVE`: models were trained successfully before, but - // cannot be refreshed because model no longer has sufficient - // data for training. - DataState data_state = 16 [(google.api.field_behavior) = OUTPUT_ONLY]; - - // Optional. If `RECOMMENDATIONS_FILTERING_ENABLED`, recommendation filtering - // by attributes is enabled for the model. - RecommendationsFilteringOption filtering_option = 18 - [(google.api.field_behavior) = OPTIONAL]; - - // Output only. The list of valid serving configs associated with the - // PageOptimizationConfig. - repeated ServingConfigList serving_config_lists = 19 - [(google.api.field_behavior) = OUTPUT_ONLY]; -} diff --git a/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/model_service.proto b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/model_service.proto deleted file mode 100644 index 0b5c1c4a9f1..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/model_service.proto +++ /dev/null @@ -1,263 +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/model.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Beta"; -option go_package = "cloud.google.com/go/retail/apiv2beta/retailpb;retailpb"; -option java_multiple_files = true; -option java_outer_classname = "ModelServiceProto"; -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 performing CRUD operations on models. -// Recommendation models contain all the metadata necessary to generate a set of -// models for the `Predict()` API. A model is queried -// indirectly via a ServingConfig, which associates a model with a -// given Placement (e.g. Frequently Bought Together on Home Page). -// -// This service allows you to do the following: -// -// * Initiate training of a model. -// * Pause training of an existing model. -// * List all the available models along with their metadata. -// * Control their tuning schedule. -service ModelService { - option (google.api.default_host) = "retail.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform"; - - // Creates a new model. - rpc CreateModel(CreateModelRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/models" - body: "model" - }; - option (google.api.method_signature) = "parent,model"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2beta.Model" - metadata_type: "google.cloud.retail.v2beta.CreateModelMetadata" - }; - } - - // Gets a model. - rpc GetModel(GetModelRequest) returns (Model) { - option (google.api.http) = { - get: "/v2beta/{name=projects/*/locations/*/catalogs/*/models/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Pauses the training of an existing model. - rpc PauseModel(PauseModelRequest) returns (Model) { - option (google.api.http) = { - post: "/v2beta/{name=projects/*/locations/*/catalogs/*/models/*}:pause" - body: "*" - }; - option (google.api.method_signature) = "name"; - } - - // Resumes the training of an existing model. - rpc ResumeModel(ResumeModelRequest) returns (Model) { - option (google.api.http) = { - post: "/v2beta/{name=projects/*/locations/*/catalogs/*/models/*}:resume" - body: "*" - }; - option (google.api.method_signature) = "name"; - } - - // Deletes an existing model. - rpc DeleteModel(DeleteModelRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v2beta/{name=projects/*/locations/*/catalogs/*/models/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists all the models linked to this event store. - rpc ListModels(ListModelsRequest) returns (ListModelsResponse) { - option (google.api.http) = { - get: "/v2beta/{parent=projects/*/locations/*/catalogs/*}/models" - }; - option (google.api.method_signature) = "parent"; - } - - // Update of model metadata. Only fields that - // currently can be updated are: `filtering_option` and - // `periodic_tuning_state`. - // If other values are provided, this API method ignores them. - rpc UpdateModel(UpdateModelRequest) returns (Model) { - option (google.api.http) = { - patch: "/v2beta/{model.name=projects/*/locations/*/catalogs/*/models/*}" - body: "model" - }; - option (google.api.method_signature) = "model,update_mask"; - } - - // Tunes an existing model. - rpc TuneModel(TuneModelRequest) returns (google.longrunning.Operation) { - option (google.api.http) = { - post: "/v2beta/{name=projects/*/locations/*/catalogs/*/models/*}:tune" - body: "*" - }; - option (google.api.method_signature) = "name"; - option (google.longrunning.operation_info) = { - response_type: "google.cloud.retail.v2beta.TuneModelResponse" - metadata_type: "google.cloud.retail.v2beta.TuneModelMetadata" - }; - } -} - -// Request for creating a model. -message CreateModelRequest { - // Required. The parent resource under which to create the model. 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 payload of the [Model][google.cloud.retail.v2beta.Model] to - // create. - Model model = 2 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Whether to run a dry run to validate the request (without - // actually creating the model). - bool dry_run = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// Request for updating an existing model. -message UpdateModelRequest { - // Required. The body of the updated - // [Model][google.cloud.retail.v2beta.Model]. - Model model = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Indicates which fields in the provided 'model' to - // update. If not set, by default updates all fields. - google.protobuf.FieldMask update_mask = 2 - [(google.api.field_behavior) = OPTIONAL]; -} - -// Request for getting a model. -message GetModelRequest { - // Required. The resource name of the - // [Model][google.cloud.retail.v2beta.Model] to get. Format: - // `projects/{project_number}/locations/{location_id}/catalogs/{catalog}/models/{model_id}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Model" } - ]; -} - -// Request for pausing training of a model. -message PauseModelRequest { - // Required. The name of the model to pause. - // Format: - // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Model" } - ]; -} - -// Request for resuming training of a model. -message ResumeModelRequest { - // Required. The name of the model to resume. - // Format: - // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` - string name = 1 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for listing models associated with a resource. -message ListModelsRequest { - // Required. The parent for which to list models. - // 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 `ListModels` - // call. Provide this to retrieve the subsequent page. - string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// Request for deleting a model. -message DeleteModelRequest { - // Required. The resource name of the - // [Model][google.cloud.retail.v2beta.Model] to delete. Format: - // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Model" } - ]; -} - -// Response to a ListModelRequest. -message ListModelsResponse { - // List of Models. - repeated Model models = 1; - - // Pagination token, if not returned indicates the last page. - string next_page_token = 2; -} - -// Request to manually start a tuning process now (instead of waiting for -// the periodically scheduled tuning to happen). -message TuneModelRequest { - // Required. The resource name of the model to tune. - // Format: - // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "retail.googleapis.com/Model" } - ]; -} - -// Metadata associated with a create operation. -message CreateModelMetadata { - // The resource name of the model that this create applies to. - // Format: - // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` - string model = 1; -} - -// Metadata associated with a tune operation. -message TuneModelMetadata { - // The resource name of the model that this tune applies to. - // Format: - // `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` - string model = 1; -} - -// Response associated with a tune operation. -message TuneModelResponse {} diff --git a/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/prediction_service.proto b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/prediction_service.proto deleted file mode 100644 index ba579bdb7d0..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/prediction_service.proto +++ /dev/null @@ -1,226 +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/user_event.proto"; -import "google/protobuf/struct.proto"; - -option csharp_namespace = "Google.Cloud.Retail.V2Beta"; -option go_package = "cloud.google.com/go/retail/apiv2beta/retailpb;retailpb"; -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: "*" - additional_bindings { - post: "/v2beta/{placement=projects/*/locations/*/catalogs/*/servingConfigs/*}:predict" - body: "*" - } - }; - } -} - -// Request message for Predict method. -message PredictRequest { - // Required. Full resource name of the format: - // `{placement=projects/*/locations/global/catalogs/default_catalog/servingConfigs/*}` - // or - // `{placement=projects/*/locations/global/catalogs/default_catalog/placements/*}`. - // We recommend using the `servingConfigs` resource. `placements` is a legacy - // resource. - // The ID of the Recommendations AI serving config or placement. - // Before you can request predictions from your model, you must create at - // least one serving config or placement for it. For more information, see - // [Manage serving configs] - // (https://cloud.google.com/retail/docs/manage-configs). - // - // The full list of available serving configs can be seen at - // https://console.cloud.google.com/ai/retail/catalogs/default_catalog/configs - 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.v2beta.UserEvent.visitor_id] or - // [UserInfo.user_id][google.cloud.retail.v2beta.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.v2beta.UserEvent.visitor_id] to - // a random unique ID and leave - // [UserInfo.user_id][google.cloud.retail.v2beta.UserInfo.user_id] unset. - UserEvent user_event = 2 [(google.api.field_behavior) = REQUIRED]; - - // Maximum number of results to return. 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; - - // This field is not used; leave it unset. - string page_token = 4 [deprecated = true]; - - // 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 *no* - // results. If instead you want empty result sets to return generic - // (unfiltered) popular products, set `strictFiltering` to False in - // `PredictRequest.params`. Note that the API will never return items with - // storageStatus of "EXPIRED" or "DELETED" regardless of filter choices. - // - // If `filterSyntaxV2` is set to true under the `params` field, then - // attribute-based expressions are expected instead of the above described - // tag-based syntax. Examples: - // - // * (colors: ANY("Red", "Blue")) AND NOT (categories: ANY("Phones")) - // * (availability: ANY("IN_STOCK")) AND - // (colors: ANY("Red") OR categories: ANY("Phones")) - // - // For more information, see - // [Filter recommendations](https://cloud.google.com/retail/docs/filter-recs). - 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 a 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. - // * `filterSyntaxV2`: Boolean. False by default. If set to true, the `filter` - // field is interpreteted according to the new, attribute-based syntax. - 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.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/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/product.proto b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/product.proto deleted file mode 100644 index 188635659f8..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/product.proto +++ /dev/null @@ -1,597 +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 = "cloud.google.com/go/retail/apiv2beta/retailpb;retailpb"; -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]. - // Note that this is only applicable to - // [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] and - // [Type.COLLECTION][google.cloud.retail.v2beta.Product.Type.COLLECTION], - // and ignored for - // [Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT]. In - // general, we suggest the users to delete the stale products explicitly, - // instead of using this field to determine staleness. - // - // 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. Note that this is only - // applicable to - // [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] and - // [Type.COLLECTION][google.cloud.retail.v2beta.Product.Type.COLLECTION], - // and ignored for - // [Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT]. In - // general, we suggest the users to delete the stale products explicitly, - // instead of using this field to determine staleness. - // - // 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 - // an 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, 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]. - // Note that this is only applicable to - // [Type.PRIMARY][google.cloud.retail.v2beta.Product.Type.PRIMARY] and - // [Type.COLLECTION][google.cloud.retail.v2beta.Product.Type.COLLECTION], and - // ignored for - // [Type.VARIANT][google.cloud.retail.v2beta.Product.Type.VARIANT]. - 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] - // - // The maximum number of paths is 30. Otherwise, an INVALID_ARGUMENT error is - // returned. - // - // Note: Returning more fields in - // [SearchResponse][google.cloud.retail.v2beta.SearchResponse] can increase - // response payload size and serving latency. - // - // This field is deprecated. Use the retrievable site-wide control instead. - google.protobuf.FieldMask retrievable_fields = 30 [deprecated = true]; - - // 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]; - - // Output only. A list of local inventories specific to different places. - // - // This field can be managed by - // [ProductService.AddLocalInventories][google.cloud.retail.v2beta.ProductService.AddLocalInventories] - // and - // [ProductService.RemoveLocalInventories][google.cloud.retail.v2beta.ProductService.RemoveLocalInventories] - // APIs if fine-grained, high-volume updates are necessary. - repeated LocalInventory local_inventories = 35 - [(google.api.field_behavior) = OUTPUT_ONLY]; -} diff --git a/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/product_service.proto b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/product_service.proto deleted file mode 100644 index edf21245404..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/product_service.proto +++ /dev/null @@ -1,925 +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 = "cloud.google.com/go/retail/apiv2beta/retailpb;retailpb"; -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. - // 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 is 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 - // [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] - // or - // [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. - // - // When inventory is updated with - // [ProductService.CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] - // and - // [ProductService.UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct], - // the specified inventory field value(s) overwrite any existing value(s) - // while ignoring the last update time for this field. Furthermore, the last - // update times for the specified inventory fields are overwritten by the - // times of the - // [ProductService.CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] - // or - // [ProductService.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 is used. - // - // If no inventory fields are set in - // [SetInventoryRequest.set_mask][google.cloud.retail.v2beta.SetInventoryRequest.set_mask], - // then any existing inventory information is preserved. - // - // Pre-existing inventory information can only be updated with - // [ProductService.SetInventory][google.cloud.retail.v2beta.ProductService.SetInventory], - // [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.AddFulfillmentPlaces], - // and - // [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces]. - // - // The returned [Operation][google.longrunning.Operation]s is obsolete after - // one day, and the [GetOperation][google.longrunning.Operations.GetOperation] - // API returns `NOT_FOUND` afterwards. - // - // If conflicting updates are issued, the - // [Operation][google.longrunning.Operation]s associated with the stale - // updates are not marked as [done][google.longrunning.Operation.done] until - // they are obsolete. - 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" - }; - } - - // It is recommended to use the - // [ProductService.AddLocalInventories][google.cloud.retail.v2beta.ProductService.AddLocalInventories] - // method instead of - // [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.AddFulfillmentPlaces]. - // [ProductService.AddLocalInventories][google.cloud.retail.v2beta.ProductService.AddLocalInventories] - // achieves the same results but provides more fine-grained control over - // ingesting local inventory data. - // - // 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 - // [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] - // or - // [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. - // - // The returned [Operation][google.longrunning.Operation]s will be obsolete - // after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] - // API will return NOT_FOUND afterwards. - // - // If conflicting updates are issued, the - // [Operation][google.longrunning.Operation]s associated with the stale - // updates will not be marked as [done][google.longrunning.Operation.done] - // until being obsolete. - 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" - }; - } - - // It is recommended to use the - // [ProductService.RemoveLocalInventories][google.cloud.retail.v2beta.ProductService.RemoveLocalInventories] - // method instead of - // [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces]. - // [ProductService.RemoveLocalInventories][google.cloud.retail.v2beta.ProductService.RemoveLocalInventories] - // achieves the same results but provides more fine-grained control over - // ingesting local inventory data. - // - // 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 - // [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] - // or - // [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. - // - // The returned [Operation][google.longrunning.Operation]s will be obsolete - // after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] - // API will return NOT_FOUND afterwards. - // - // If conflicting updates are issued, the - // [Operation][google.longrunning.Operation]s associated with the stale - // updates will not be marked as [done][google.longrunning.Operation.done] - // until being obsolete. - 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 - // [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] - // or - // [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. - // - // Local inventory information can only be modified using this method. - // [ProductService.CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] - // and - // [ProductService.UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct] - // has no effect on local inventories. - // - // The returned [Operation][google.longrunning.Operation]s will be obsolete - // after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] - // API will return NOT_FOUND afterwards. - // - // If conflicting updates are issued, the - // [Operation][google.longrunning.Operation]s associated with the stale - // updates will not be marked as [done][google.longrunning.Operation.done] - // until being obsolete. - 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 - // [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] - // or - // [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. - // - // Local inventory information can only be removed using this method. - // [ProductService.CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] - // and - // [ProductService.UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct] - // has no effect on local inventories. - // - // The returned [Operation][google.longrunning.Operation]s will be obsolete - // after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] - // API will return NOT_FOUND afterwards. - // - // If conflicting updates are issued, the - // [Operation][google.longrunning.Operation]s associated with the stale - // updates will not be marked as [done][google.longrunning.Operation.done] - // until being obsolete. - 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 -// [ProductService.CreateProduct][google.cloud.retail.v2beta.ProductService.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 -// [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.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 -// [ProductService.UpdateProduct][google.cloud.retail.v2beta.ProductService.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. - // - // 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.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 -// [ProductService.DeleteProduct][google.cloud.retail.v2beta.ProductService.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 -// [ProductService.SetInventory][google.cloud.retail.v2beta.ProductService.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][google.cloud.retail.v2beta.Product.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][google.cloud.retail.v2beta.Product.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][google.cloud.retail.v2beta.Product.fulfillment_info] - // * Checks that only the desired fulfillment info types have empty - // [SetInventoryRequest.inventory.fulfillment_info.place_ids][google.cloud.retail.v2beta.FulfillmentInfo.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, - // [ProductService.UpdateProduct][google.cloud.retail.v2beta.ProductService.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 -// [ProductService.SetInventory][google.cloud.retail.v2beta.ProductService.SetInventory] -// method. -message SetInventoryMetadata {} - -// Response of the SetInventoryRequest. Currently empty because -// there is no meaningful response populated from the -// [ProductService.SetInventory][google.cloud.retail.v2beta.ProductService.SetInventory] -// method. -message SetInventoryResponse {} - -// Request message for -// [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.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][google.cloud.retail.v2beta.FulfillmentInfo.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 -// [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2beta.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.v2beta.ProductService.AddFulfillmentPlaces] -// method. -message AddFulfillmentPlacesResponse {} - -// Request message for -// [ProductService.AddLocalInventories][google.cloud.retail.v2beta.ProductService.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 -// [ProductService.AddLocalInventories][google.cloud.retail.v2beta.ProductService.AddLocalInventories] -// method. -message AddLocalInventoriesMetadata {} - -// Response of the -// [ProductService.AddLocalInventories][google.cloud.retail.v2beta.ProductService.AddLocalInventories] -// API. Currently empty because there is no meaningful response populated from -// the -// [ProductService.AddLocalInventories][google.cloud.retail.v2beta.ProductService.AddLocalInventories] -// method. -message AddLocalInventoriesResponse {} - -// Request message for -// [ProductService.RemoveLocalInventories][google.cloud.retail.v2beta.ProductService.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 -// [ProductService.RemoveLocalInventories][google.cloud.retail.v2beta.ProductService.RemoveLocalInventories] -// method. -message RemoveLocalInventoriesMetadata {} - -// Response of the -// [ProductService.RemoveLocalInventories][google.cloud.retail.v2beta.ProductService.RemoveLocalInventories] -// API. Currently empty because there is no meaningful response populated from -// the -// [ProductService.RemoveLocalInventories][google.cloud.retail.v2beta.ProductService.RemoveLocalInventories] -// method. -message RemoveLocalInventoriesResponse {} - -// Request message for -// [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.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][google.cloud.retail.v2beta.FulfillmentInfo.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 -// [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces] -// method. -message RemoveFulfillmentPlacesMetadata {} - -// Response of the RemoveFulfillmentPlacesRequest. Currently empty because there -// is no meaningful response populated from the -// [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces] -// method. -message RemoveFulfillmentPlacesResponse {} diff --git a/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/promotion.proto b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/promotion.proto deleted file mode 100644 index e388f3aeb7a..00000000000 --- a/owl-bot-staging/google-cloud-retail/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 = "cloud.google.com/go/retail/apiv2beta/retailpb;retailpb"; -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/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/purge_config.proto b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/purge_config.proto deleted file mode 100644 index 377c465499a..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/purge_config.proto +++ /dev/null @@ -1,83 +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 = "cloud.google.com/go/retail/apiv2beta/retailpb;retailpb"; -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, - (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.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/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/search_service.proto b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/search_service.proto deleted file mode 100644 index efd7fc27e48..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/search_service.proto +++ /dev/null @@ -1,990 +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 = "cloud.google.com/go/retail/apiv2beta/retailpb;retailpb"; -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"; -option (google.api.resource_definition) = { - type: "retail.googleapis.com/Experiment" - pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/experiments/{experiment}" -}; - -// Service for search. -// -// This feature is only available for users who have Retail Search enabled. -// 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. - // 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: "*" - additional_bindings { - post: "/v2beta/{placement=projects/*/locations/*/catalogs/*/servingConfigs/*}: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 40. - // - // For all numerical facet keys that appear in the list of products from - // the catalog, the percentiles 0, 10, 30, 50, 70, 90 and 100 are - // computed from their distribution weekly. If the model assigns a high - // score to a numerical facet key and its intervals are not specified in - // the search request, these percentiles will become the bounds - // for its intervals and will be returned in the response. If the - // facet key intervals are specified in the request, then the specified - // intervals will be returned instead. - 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; - - // True to make facet keys case insensitive when getting faceting - // values with prefixes or contains; false otherwise. - bool case_insensitive = 10; - - // The order in which - // [SearchResponse.Facet.values][google.cloud.retail.v2beta.SearchResponse.Facet.values] - // are returned. - // - // Allowed values are: - // - // * "count desc", which means order by - // [SearchResponse.Facet.values.count][google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue.count] - // descending. - // - // * "value desc", which means order by - // [SearchResponse.Facet.values.value][google.cloud.retail.v2beta.SearchResponse.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, - // [SearchResponse.Facet.values.value][google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue.value] - // will be always "1" and - // [SearchResponse.Facet.values.count][google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue.count] - // will be the number of results that match 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; - - // Returns the min and max value for each numerical facet intervals. - // Ignored for textual facets. - bool return_min_max = 11; - } - - // 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 50. 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. - // - // 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.v2beta.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.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 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.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. In this case, server behavior - // 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. In this case, server behavior defaults to - // [Mode.AUTO][google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.Mode.AUTO]. - MODE_UNSPECIFIED = 0; - - // Let CRS decide whether to use personalization based on quality of user - // event data. - AUTO = 1; - - // Disable personalization. - DISABLED = 2; - } - - // Defaults to - // [Mode.AUTO][google.cloud.retail.v2beta.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. In this case, server behavior - // defaults to - // [Mode.AUTO][google.cloud.retail.v2beta.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.v2beta.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.v2beta.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][google.cloud.retail.v2beta.SearchResponse.SearchResult] - // and - // [SearchResponse.Facet][google.cloud.retail.v2beta.SearchResponse.Facet] - // will be returned. - SEARCH_MODE_UNSPECIFIED = 0; - - // Only product search will be performed. The faceted search will be - // disabled. - // - // Only - // [SearchResponse.SearchResult][google.cloud.retail.v2beta.SearchResponse.SearchResult] - // will be returned. - // [SearchResponse.Facet][google.cloud.retail.v2beta.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_specs][google.cloud.retail.v2beta.SearchRequest.facet_specs] - // 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][google.cloud.retail.v2beta.SearchResponse.Facet] - // will be returned. - // [SearchResponse.SearchResult][google.cloud.retail.v2beta.SearchResponse.SearchResult] - // will not be returned. - FACETED_SEARCH_ONLY = 2; - } - - // Required. The resource name of the Retail Search serving config, such as - // `projects/*/locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` - // or the name of the legacy placement resource, such as - // `projects/*/locations/global/catalogs/default_catalog/placements/default_search`. - // This field is used to identify the serving config 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.v2beta.SearchRequest.filter] and - // [page_categories][google.cloud.retail.v2beta.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.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 200 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][google.cloud.retail.v2beta.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.local_inventories.attributes][google.cloud.retail.v2beta.LocalInventory.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. Must be set 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, 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. - // - // Notice that if both - // [ServingConfig.personalization_spec][google.cloud.retail.v2beta.ServingConfig.personalization_spec] - // and - // [SearchRequest.personalization_spec][google.cloud.retail.v2beta.SearchRequest.personalization_spec] - // are set. - // [SearchRequest.personalization_spec][google.cloud.retail.v2beta.SearchRequest.personalization_spec] - // will override - // [ServingConfig.personalization_spec][google.cloud.retail.v2beta.ServingConfig.personalization_spec]. - 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; - - // The entity for customers that may run multiple different entities, domains, - // sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, - // `google.com`, `youtube.com`, etc. - // If this is set, it should be exactly matched with - // [UserEvent.entity][google.cloud.retail.v2beta.UserEvent.entity] to get - // search results boosted by entity. - string entity = 38; -} - -// 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; - - // Specifies previous events related to this product for this user based on - // [UserEvent][google.cloud.retail.v2beta.UserEvent] with same - // [SearchRequest.visitor_id][google.cloud.retail.v2beta.SearchRequest.visitor_id] - // or [UserInfo.user_id][google.cloud.retail.v2beta.UserInfo.user_id]. - // - // This is set only when - // [SearchRequest.PersonalizationSpec.mode][google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.mode] - // is - // [SearchRequest.PersonalizationSpec.Mode.AUTO][google.cloud.retail.v2beta.SearchRequest.PersonalizationSpec.Mode.AUTO]. - // - // Possible values: - // - // * `purchased`: Indicates that this product has been purchased before. - repeated string personal_labels = 7; - } - - // 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 minimum value in the - // [FacetValue.interval][google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue.interval]. - // Only supported on numerical facets and returned if - // [SearchRequest.FacetSpec.FacetKey.return_min_max][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.return_min_max] - // is true. - double min_value = 5; - - // The maximum value in the - // [FacetValue.interval][google.cloud.retail.v2beta.SearchResponse.Facet.FacetValue.interval]. - // Only supported on numerical facets and returned if - // [SearchRequest.FacetSpec.FacetKey.return_min_max][google.cloud.retail.v2beta.SearchRequest.FacetSpec.FacetKey.return_min_max] - // is true. - double max_value = 6; - } - - // 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; - - // 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 is used for search. - 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 is performed, and only - // [redirect_uri][google.cloud.retail.v2beta.SearchResponse.redirect_uri] and - // [attribution_token][google.cloud.retail.v2beta.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.v2beta.SearchRequest.BoostSpec.condition_boost_specs] - // that are not applied during serving. - repeated SearchRequest.BoostSpec.ConditionBoostSpec - invalid_condition_boost_specs = 14; - - // Metadata related to A/B testing [Experiment][] associated with this - // response. Only exists when an experiment is triggered. - repeated ExperimentInfo experiment_info = 17; -} - -// Metadata for active A/B testing [Experiments][]. -message ExperimentInfo { - // Metadata for active serving config A/B tests. - message ServingConfigExperiment { - // The fully qualified resource name of the original - // [SearchRequest.placement][google.cloud.retail.v2beta.SearchRequest.placement] - // in the search request prior to reassignment by experiment API. For - // example: `projects/*/locations/*/catalogs/*/servingConfigs/*`. - string original_serving_config = 1 [(google.api.resource_reference) = { - type: "retail.googleapis.com/ServingConfig" - }]; - - // The fully qualified resource name of the serving config - // [VariantArm.serving_config_id][] responsible for generating the search - // response. For example: - // `projects/*/locations/*/catalogs/*/servingConfigs/*`. - string experiment_serving_config = 2 [(google.api.resource_reference) = { - type: "retail.googleapis.com/ServingConfig" - }]; - } - - // Information associated with the specific experiment entity being recorded. - oneof experiment_metadata { - // A/B test between existing Cloud Retail Search - // [ServingConfig][google.cloud.retail.v2beta.ServingConfig]s. - ServingConfigExperiment serving_config_experiment = 2; - } - - // The fully qualified resource name of the experiment that provides the - // serving config under test, should an active experiment exist. For example: - // `projects/*/locations/global/catalogs/default_catalog/experiments/experiment_id` - string experiment = 1 [(google.api.resource_reference) = { - type: "retail.googleapis.com/Experiment" - }]; -} diff --git a/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/serving_config.proto b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/serving_config.proto deleted file mode 100644 index 45dd103f9c7..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/serving_config.proto +++ /dev/null @@ -1,281 +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 = "cloud.google.com/go/retail/apiv2beta/retailpb;retailpb"; -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). -message ServingConfig { - option (google.api.resource) = { - type: "retail.googleapis.com/ServingConfig" - pattern: "projects/{project}/locations/{location}/catalogs/{catalog}/servingConfigs/{serving_config}" - }; - - // What type of diversity - data or rule based. - enum DiversityType { - // Default value. - DIVERSITY_TYPE_UNSPECIFIED = 0; - - // Rule based diversity. - RULE_BASED_DIVERSITY = 2; - - // Data driven diversity. - DATA_DRIVEN_DIVERSITY = 3; - } - - // 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 in the same - // [Catalog][google.cloud.retail.v2beta.Catalog] 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-reranking` - // * `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][google.cloud.retail.v2beta.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; - - // What kind of diversity to use - data driven or rule based. If unset, the - // server behavior defaults to - // [RULE_BASED_DIVERSITY][google.cloud.retail.v2beta.ServingConfig.DiversityType.RULE_BASED_DIVERSITY]. - DiversityType diversity_type = 20; - - // 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; - - // The specification for personalization spec. - // - // 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]. - // - // Notice that if both - // [ServingConfig.personalization_spec][google.cloud.retail.v2beta.ServingConfig.personalization_spec] - // and - // [SearchRequest.personalization_spec][google.cloud.retail.v2beta.SearchRequest.personalization_spec] - // are set. - // [SearchRequest.personalization_spec][google.cloud.retail.v2beta.SearchRequest.personalization_spec] - // will override - // [ServingConfig.personalization_spec][google.cloud.retail.v2beta.ServingConfig.personalization_spec]. - SearchRequest.PersonalizationSpec personalization_spec = 21; - - // 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/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/serving_config_service.proto b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/serving_config_service.proto deleted file mode 100644 index 66b210b3ab1..00000000000 --- a/owl-bot-staging/google-cloud-retail/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 = "cloud.google.com/go/retail/apiv2beta/retailpb;retailpb"; -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/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/user_event.proto b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/user_event.proto deleted file mode 100644 index c212b9de242..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/user_event.proto +++ /dev/null @@ -1,352 +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 = "cloud.google.com/go/retail/apiv2beta/retailpb;retailpb"; -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. - // - // 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.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 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.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, 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; - - // The entity for customers that may run multiple different entities, domains, - // sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, - // `google.com`, `youtube.com`, etc. - // It is recommended to set this field to get better per-entity search, - // completion and prediction results. - string entity = 23; -} - -// 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/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/user_event_service.proto b/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/user_event_service.proto deleted file mode 100644 index d6a9b0e6016..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/protos/google/cloud/retail/v2beta/user_event_service.proto +++ /dev/null @@ -1,210 +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 = "cloud.google.com/go/retail/apiv2beta/retailpb;retailpb"; -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 - // are not annotated with detailed product information for products that are - // missing from the catalog when the user event is ingested. These - // events are stored as unjoined events with limited usage on training and - // serving. You can use this method to start a join operation on specified - // events with the latest version of product catalog. You can also use this - // method 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]; - - // If set to true, the user event will be written asynchronously after - // validation, and the API will respond without waiting for the write. - // Therefore, silent failures can occur even if the API returns success. In - // case of silent failures, error messages can be found in Stackdriver logs. - bool write_async = 3; -} - -// Request message for CollectUserEvent method. -message CollectUserEventRequest { - // The rule that can convert the raw_json to a user event. It is needed - // only when the raw_json is set. - oneof conversion_rule { - // The prebuilt rule name that can convert a specific type of raw_json. - // For example: "ga4_bq" rule for the GA4 user event schema. - string prebuilt_rule = 6; - } - - // 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; - - // An arbitrary serialized JSON string that contains necessary information - // that can comprise a user event. When this field is specified, the - // user_event field will be ignored. Note: line-delimited JSON is not - // supported, a single JSON only. - string raw_json = 5; -} - -// 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/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.add_catalog_attribute.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.add_catalog_attribute.js deleted file mode 100644 index 5e4c695ad60..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.add_catalog_attribute.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.batch_remove_catalog_attributes.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.batch_remove_catalog_attributes.js deleted file mode 100644 index 1b022e70542..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.batch_remove_catalog_attributes.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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, attributeKeys) { - // [START retail_v2beta_generated_CatalogService_BatchRemoveCatalogAttributes_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The attributes config resource shared by all catalog attributes - * being deleted. Format: - * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` - */ - // const attributesConfig = 'abc123' - /** - * Required. The attribute name keys of the - * CatalogAttribute google.cloud.retail.v2beta.CatalogAttribute s to delete. - * A maximum of 1000 catalog attributes can be deleted in a batch. - */ - // const attributeKeys = 'abc123' - - // Imports the Retail library - const {CatalogServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new CatalogServiceClient(); - - async function callBatchRemoveCatalogAttributes() { - // Construct request - const request = { - attributesConfig, - attributeKeys, - }; - - // Run request - const response = await retailClient.batchRemoveCatalogAttributes(request); - console.log(response); - } - - callBatchRemoveCatalogAttributes(); - // [END retail_v2beta_generated_CatalogService_BatchRemoveCatalogAttributes_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.get_attributes_config.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.get_attributes_config.js deleted file mode 100644 index 83a8ed770fe..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.get_attributes_config.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.get_completion_config.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.get_completion_config.js deleted file mode 100644 index 2b9350d8058..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.get_completion_config.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.get_default_branch.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.get_default_branch.js deleted file mode 100644 index 111b3ffe60e..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.get_default_branch.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.list_catalogs.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.list_catalogs.js deleted file mode 100644 index 64a3f18de45..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.list_catalogs.js +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.remove_catalog_attribute.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.remove_catalog_attribute.js deleted file mode 100644 index b453231d24d..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.remove_catalog_attribute.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.replace_catalog_attribute.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.replace_catalog_attribute.js deleted file mode 100644 index e3802ca5272..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.replace_catalog_attribute.js +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.set_default_branch.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.set_default_branch.js deleted file mode 100644 index 094ae12bc02..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.set_default_branch.js +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.update_attributes_config.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.update_attributes_config.js deleted file mode 100644 index 2da5b62268c..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.update_attributes_config.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.update_catalog.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.update_catalog.js deleted file mode 100644 index ff13c43501e..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.update_catalog.js +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.update_completion_config.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.update_completion_config.js deleted file mode 100644 index 1eb92415ea6..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/catalog_service.update_completion_config.js +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2beta/samples/generated/v2beta/completion_service.complete_query.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/completion_service.complete_query.js deleted file mode 100644 index ebb8fe33588..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/completion_service.complete_query.js +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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' - /** - * Note that this field applies for `user-data` dataset only. For requests - * with `cloud-retail` dataset, setting this field has no effect. - * 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. We recommend that you - * leave this field empty. - * It can 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 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 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 - /** - * The entity for customers that may run multiple different entities, domains, - * sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, - * `google.com`, `youtube.com`, etc. - * If this is set, it should be exactly matched with - * UserEvent.entity google.cloud.retail.v2beta.UserEvent.entity to get - * per-entity autocomplete results. - */ - // const entity = 'abc123' - - // 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/google-cloud-retail/v2beta/samples/generated/v2beta/completion_service.import_completion_data.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/completion_service.import_completion_data.js deleted file mode 100644 index 6d1469d212d..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/completion_service.import_completion_data.js +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 is sent to - * specified Pub/Sub topic. The message data is 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/google-cloud-retail/v2beta/samples/generated/v2beta/control_service.create_control.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/control_service.create_control.js deleted file mode 100644 index 227139e6cc9..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/control_service.create_control.js +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2beta/samples/generated/v2beta/control_service.delete_control.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/control_service.delete_control.js deleted file mode 100644 index ffa79ce76ae..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/control_service.delete_control.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the 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/google-cloud-retail/v2beta/samples/generated/v2beta/control_service.get_control.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/control_service.get_control.js deleted file mode 100644 index 0c0cccc9269..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/control_service.get_control.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the Control to get. 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/google-cloud-retail/v2beta/samples/generated/v2beta/control_service.list_controls.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/control_service.list_controls.js deleted file mode 100644 index e690fb51cee..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/control_service.list_controls.js +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2beta/samples/generated/v2beta/control_service.update_control.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/control_service.update_control.js deleted file mode 100644 index 25d7ee12766..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/control_service.update_control.js +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.create_model.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.create_model.js deleted file mode 100644 index 2ab35505f85..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.create_model.js +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, model) { - // [START retail_v2beta_generated_ModelService_CreateModel_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent resource under which to create the model. Format: - * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` - */ - // const parent = 'abc123' - /** - * Required. The payload of the Model google.cloud.retail.v2beta.Model to - * create. - */ - // const model = {} - /** - * Optional. Whether to run a dry run to validate the request (without - * actually creating the model). - */ - // const dryRun = true - - // Imports the Retail library - const {ModelServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ModelServiceClient(); - - async function callCreateModel() { - // Construct request - const request = { - parent, - model, - }; - - // Run request - const [operation] = await retailClient.createModel(request); - const [response] = await operation.promise(); - console.log(response); - } - - callCreateModel(); - // [END retail_v2beta_generated_ModelService_CreateModel_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.delete_model.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.delete_model.js deleted file mode 100644 index 2e2163f51e7..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.delete_model.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by 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_ModelService_DeleteModel_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the - * Model google.cloud.retail.v2beta.Model to delete. Format: - * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` - */ - // const name = 'abc123' - - // Imports the Retail library - const {ModelServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ModelServiceClient(); - - async function callDeleteModel() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.deleteModel(request); - console.log(response); - } - - callDeleteModel(); - // [END retail_v2beta_generated_ModelService_DeleteModel_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.get_model.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.get_model.js deleted file mode 100644 index a5439a36581..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.get_model.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by 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_ModelService_GetModel_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the - * Model google.cloud.retail.v2beta.Model to get. Format: - * `projects/{project_number}/locations/{location_id}/catalogs/{catalog}/models/{model_id}` - */ - // const name = 'abc123' - - // Imports the Retail library - const {ModelServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ModelServiceClient(); - - async function callGetModel() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.getModel(request); - console.log(response); - } - - callGetModel(); - // [END retail_v2beta_generated_ModelService_GetModel_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.list_models.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.list_models.js deleted file mode 100644 index 63a8d86deb5..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.list_models.js +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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_ModelService_ListModels_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent for which to list models. - * 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 `ListModels` - * call. Provide this to retrieve the subsequent page. - */ - // const pageToken = 'abc123' - - // Imports the Retail library - const {ModelServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ModelServiceClient(); - - async function callListModels() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await retailClient.listModelsAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListModels(); - // [END retail_v2beta_generated_ModelService_ListModels_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.pause_model.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.pause_model.js deleted file mode 100644 index 3b0f9375fda..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.pause_model.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by 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_ModelService_PauseModel_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the model to pause. - * Format: - * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` - */ - // const name = 'abc123' - - // Imports the Retail library - const {ModelServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ModelServiceClient(); - - async function callPauseModel() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.pauseModel(request); - console.log(response); - } - - callPauseModel(); - // [END retail_v2beta_generated_ModelService_PauseModel_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.resume_model.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.resume_model.js deleted file mode 100644 index e045255bf49..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.resume_model.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by 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_ModelService_ResumeModel_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the model to resume. - * Format: - * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` - */ - // const name = 'abc123' - - // Imports the Retail library - const {ModelServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ModelServiceClient(); - - async function callResumeModel() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await retailClient.resumeModel(request); - console.log(response); - } - - callResumeModel(); - // [END retail_v2beta_generated_ModelService_ResumeModel_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.tune_model.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.tune_model.js deleted file mode 100644 index 94ff8952158..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.tune_model.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by 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_ModelService_TuneModel_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the model to tune. - * Format: - * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_id}` - */ - // const name = 'abc123' - - // Imports the Retail library - const {ModelServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ModelServiceClient(); - - async function callTuneModel() { - // Construct request - const request = { - name, - }; - - // Run request - const [operation] = await retailClient.tuneModel(request); - const [response] = await operation.promise(); - console.log(response); - } - - callTuneModel(); - // [END retail_v2beta_generated_ModelService_TuneModel_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.update_model.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.update_model.js deleted file mode 100644 index 4739e4868a2..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/model_service.update_model.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(model) { - // [START retail_v2beta_generated_ModelService_UpdateModel_async] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The body of the updated - * Model google.cloud.retail.v2beta.Model. - */ - // const model = {} - /** - * Optional. Indicates which fields in the provided 'model' to - * update. If not set, by default updates all fields. - */ - // const updateMask = {} - - // Imports the Retail library - const {ModelServiceClient} = require('@google-cloud/retail').v2beta; - - // Instantiates a client - const retailClient = new ModelServiceClient(); - - async function callUpdateModel() { - // Construct request - const request = { - model, - }; - - // Run request - const response = await retailClient.updateModel(request); - console.log(response); - } - - callUpdateModel(); - // [END retail_v2beta_generated_ModelService_UpdateModel_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/prediction_service.predict.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/prediction_service.predict.js deleted file mode 100644 index f0c9bf0bcf5..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/prediction_service.predict.js +++ /dev/null @@ -1,187 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. Full resource name of the format: - * `{placement=projects/* /locations/global/catalogs/default_catalog/servingConfigs/*}` - * or - * `{placement=projects/* /locations/global/catalogs/default_catalog/placements/*}`. - * We recommend using the `servingConfigs` resource. `placements` is a legacy - * resource. - * The ID of the Recommendations AI serving config or placement. - * Before you can request predictions from your model, you must create at - * least one serving config or placement for it. For more information, see - * Manage serving configs - * (https://cloud.google.com/retail/docs/manage-configs). - * The full list of available serving configs can be seen at - * https://console.cloud.google.com/ai/retail/catalogs/default_catalog/configs - */ - // 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.v2beta.UserEvent.visitor_id or - * UserInfo.user_id google.cloud.retail.v2beta.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.v2beta.UserEvent.visitor_id to - * a random unique ID and leave - * UserInfo.user_id google.cloud.retail.v2beta.UserInfo.user_id unset. - */ - // const userEvent = {} - /** - * Maximum number of results to return. 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 - /** - * This field is not used; leave it unset. - */ - // 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 *no* - * results. If instead you want empty result sets to return generic - * (unfiltered) popular products, set `strictFiltering` to False in - * `PredictRequest.params`. Note that the API will never return items with - * storageStatus of "EXPIRED" or "DELETED" regardless of filter choices. - * If `filterSyntaxV2` is set to true under the `params` field, then - * attribute-based expressions are expected instead of the above described - * tag-based syntax. Examples: - * * (colors: ANY("Red", "Blue")) AND NOT (categories: ANY("Phones")) - * * (availability: ANY("IN_STOCK")) AND - * (colors: ANY("Red") OR categories: ANY("Phones")) - * For more information, see - * Filter recommendations (https://cloud.google.com/retail/docs/filter-recs). - */ - // 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 a 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. - * * `filterSyntaxV2`: Boolean. False by default. If set to true, the `filter` - * field is interpreteted according to the new, attribute-based syntax. - */ - // 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/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.add_fulfillment_places.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.add_fulfillment_places.js deleted file mode 100644 index 58f6e51f2af..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.add_fulfillment_places.js +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 google.cloud.retail.v2beta.FulfillmentInfo.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/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.add_local_inventories.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.add_local_inventories.js deleted file mode 100644 index bb414c8239c..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.add_local_inventories.js +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.create_product.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.create_product.js deleted file mode 100644 index c679daa8f4b..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.create_product.js +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent 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/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.delete_product.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.delete_product.js deleted file mode 100644 index 7f4ad6857bf..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.delete_product.js +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.get_product.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.get_product.js deleted file mode 100644 index 5c560a26297..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.get_product.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.import_products.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.import_products.js deleted file mode 100644 index 7e782bcf518..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.import_products.js +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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, all fields are updated. - */ - // 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 = {} - /** - * Full Pub/Sub topic name for receiving notification. If this field is set, - * when the import is finished, a notification is sent to - * specified Pub/Sub topic. The message data is 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.v2beta.ImportProductsRequest.parent. - * Make sure that `service-@gcp-sa-retail.iam.gserviceaccount.com` has the - * `pubsub.topics.publish` IAM permission on the topic. - */ - // 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/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.list_products.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.list_products.js deleted file mode 100644 index 4fb5552ed46..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.list_products.js +++ /dev/null @@ -1,135 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent 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/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.remove_fulfillment_places.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.remove_fulfillment_places.js deleted file mode 100644 index 1e7936544cf..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.remove_fulfillment_places.js +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 google.cloud.retail.v2beta.FulfillmentInfo.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/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.remove_local_inventories.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.remove_local_inventories.js deleted file mode 100644 index 24da928bae0..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.remove_local_inventories.js +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.set_inventory.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.set_inventory.js deleted file mode 100644 index 42222a34431..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.set_inventory.js +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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 google.cloud.retail.v2beta.Product.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 google.cloud.retail.v2beta.Product.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 google.cloud.retail.v2beta.Product.fulfillment_info - * * Checks that only the desired fulfillment info types have empty - * SetInventoryRequest.inventory.fulfillment_info.place_ids google.cloud.retail.v2beta.FulfillmentInfo.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, - * ProductService.UpdateProduct google.cloud.retail.v2beta.ProductService.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/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.update_product.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.update_product.js deleted file mode 100644 index 1c302af33bb..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/product_service.update_product.js +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The product 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. - * 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.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/google-cloud-retail/v2beta/samples/generated/v2beta/search_service.search.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/search_service.search.js deleted file mode 100644 index a413ab297da..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/search_service.search.js +++ /dev/null @@ -1,312 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the Retail Search serving config, such as - * `projects/* /locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` - * or the name of the legacy placement resource, such as - * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. - * This field is used to identify the serving config 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.v2beta.SearchRequest.filter and - * page_categories google.cloud.retail.v2beta.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.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 200 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 google.cloud.retail.v2beta.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.local_inventories.attributes google.cloud.retail.v2beta.LocalInventory.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. Must be set 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, 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. - * Notice that if both - * ServingConfig.personalization_spec google.cloud.retail.v2beta.ServingConfig.personalization_spec - * and - * SearchRequest.personalization_spec google.cloud.retail.v2beta.SearchRequest.personalization_spec - * are set. - * SearchRequest.personalization_spec google.cloud.retail.v2beta.SearchRequest.personalization_spec - * will override - * ServingConfig.personalization_spec google.cloud.retail.v2beta.ServingConfig.personalization_spec. - */ - // 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 = {} - /** - * The entity for customers that may run multiple different entities, domains, - * sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, - * `google.com`, `youtube.com`, etc. - * If this is set, it should be exactly matched with - * UserEvent.entity google.cloud.retail.v2beta.UserEvent.entity to get - * search results boosted by entity. - */ - // const entity = 'abc123' - - // 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/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.add_control.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.add_control.js deleted file mode 100644 index 1ab65c31508..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.add_control.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.create_serving_config.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.create_serving_config.js deleted file mode 100644 index 46fae64ce42..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.create_serving_config.js +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.delete_serving_config.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.delete_serving_config.js deleted file mode 100644 index 4544ae252d1..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.delete_serving_config.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the 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/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.get_serving_config.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.get_serving_config.js deleted file mode 100644 index 1ea818c54e2..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.get_serving_config.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the 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/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.list_serving_configs.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.list_serving_configs.js deleted file mode 100644 index bbcda9947ba..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.list_serving_configs.js +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.remove_control.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.remove_control.js deleted file mode 100644 index 7009be17e3d..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.remove_control.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.update_serving_config.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.update_serving_config.js deleted file mode 100644 index 5e2aa38f5a1..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/serving_config_service.update_serving_config.js +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2beta/samples/generated/v2beta/snippet_metadata.google.cloud.retail.v2beta.json b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/snippet_metadata.google.cloud.retail.v2beta.json deleted file mode 100644 index e64b2a33b6f..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/snippet_metadata.google.cloud.retail.v2beta.json +++ /dev/null @@ -1,2543 +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": 78, - "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": 65, - "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": 76, - "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": 53, - "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": 54, - "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": 70, - "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": 54, - "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": 62, - "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": 60, - "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": 60, - "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_BatchRemoveCatalogAttributes_async", - "title": "CatalogService batchRemoveCatalogAttributes Sample", - "origin": "API_DEFINITION", - "description": " Removes all specified [CatalogAttribute][google.cloud.retail.v2beta.CatalogAttribute]s from the [AttributesConfig][google.cloud.retail.v2beta.AttributesConfig].", - "canonical": true, - "file": "catalog_service.batch_remove_catalog_attributes.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 62, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "BatchRemoveCatalogAttributes", - "fullName": "google.cloud.retail.v2beta.CatalogService.BatchRemoveCatalogAttributes", - "async": true, - "parameters": [ - { - "name": "attributes_config", - "type": "TYPE_STRING" - }, - { - "name": "attribute_keys", - "type": "TYPE_STRING[]" - } - ], - "resultType": ".google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse", - "client": { - "shortName": "CatalogServiceClient", - "fullName": "google.cloud.retail.v2beta.CatalogServiceClient" - }, - "method": { - "shortName": "BatchRemoveCatalogAttributes", - "fullName": "google.cloud.retail.v2beta.CatalogService.BatchRemoveCatalogAttributes", - "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": 68, - "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. Enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "completion_service.complete_query.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 124, - "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" - }, - { - "name": "entity", - "type": "TYPE_STRING" - } - ], - "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. 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": 68, - "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": 67, - "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": 54, - "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 update does not exist, a NOT_FOUND error is returned.", - "canonical": true, - "file": "control_service.update_control.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 61, - "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": 54, - "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 by their parent [Catalog][google.cloud.retail.v2beta.Catalog].", - "canonical": true, - "file": "control_service.list_controls.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 74, - "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_ModelService_CreateModel_async", - "title": "CatalogService createModel Sample", - "origin": "API_DEFINITION", - "description": " Creates a new model.", - "canonical": true, - "file": "model_service.create_model.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateModel", - "fullName": "google.cloud.retail.v2beta.ModelService.CreateModel", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "model", - "type": ".google.cloud.retail.v2beta.Model" - }, - { - "name": "dry_run", - "type": "TYPE_BOOL" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ModelServiceClient", - "fullName": "google.cloud.retail.v2beta.ModelServiceClient" - }, - "method": { - "shortName": "CreateModel", - "fullName": "google.cloud.retail.v2beta.ModelService.CreateModel", - "service": { - "shortName": "ModelService", - "fullName": "google.cloud.retail.v2beta.ModelService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ModelService_GetModel_async", - "title": "CatalogService getModel Sample", - "origin": "API_DEFINITION", - "description": " Gets a model.", - "canonical": true, - "file": "model_service.get_model.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetModel", - "fullName": "google.cloud.retail.v2beta.ModelService.GetModel", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2beta.Model", - "client": { - "shortName": "ModelServiceClient", - "fullName": "google.cloud.retail.v2beta.ModelServiceClient" - }, - "method": { - "shortName": "GetModel", - "fullName": "google.cloud.retail.v2beta.ModelService.GetModel", - "service": { - "shortName": "ModelService", - "fullName": "google.cloud.retail.v2beta.ModelService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ModelService_PauseModel_async", - "title": "CatalogService pauseModel Sample", - "origin": "API_DEFINITION", - "description": " Pauses the training of an existing model.", - "canonical": true, - "file": "model_service.pause_model.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "PauseModel", - "fullName": "google.cloud.retail.v2beta.ModelService.PauseModel", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2beta.Model", - "client": { - "shortName": "ModelServiceClient", - "fullName": "google.cloud.retail.v2beta.ModelServiceClient" - }, - "method": { - "shortName": "PauseModel", - "fullName": "google.cloud.retail.v2beta.ModelService.PauseModel", - "service": { - "shortName": "ModelService", - "fullName": "google.cloud.retail.v2beta.ModelService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ModelService_ResumeModel_async", - "title": "CatalogService resumeModel Sample", - "origin": "API_DEFINITION", - "description": " Resumes the training of an existing model.", - "canonical": true, - "file": "model_service.resume_model.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ResumeModel", - "fullName": "google.cloud.retail.v2beta.ModelService.ResumeModel", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.retail.v2beta.Model", - "client": { - "shortName": "ModelServiceClient", - "fullName": "google.cloud.retail.v2beta.ModelServiceClient" - }, - "method": { - "shortName": "ResumeModel", - "fullName": "google.cloud.retail.v2beta.ModelService.ResumeModel", - "service": { - "shortName": "ModelService", - "fullName": "google.cloud.retail.v2beta.ModelService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ModelService_DeleteModel_async", - "title": "CatalogService deleteModel Sample", - "origin": "API_DEFINITION", - "description": " Deletes an existing model.", - "canonical": true, - "file": "model_service.delete_model.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 55, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteModel", - "fullName": "google.cloud.retail.v2beta.ModelService.DeleteModel", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "ModelServiceClient", - "fullName": "google.cloud.retail.v2beta.ModelServiceClient" - }, - "method": { - "shortName": "DeleteModel", - "fullName": "google.cloud.retail.v2beta.ModelService.DeleteModel", - "service": { - "shortName": "ModelService", - "fullName": "google.cloud.retail.v2beta.ModelService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ModelService_ListModels_async", - "title": "CatalogService listModels Sample", - "origin": "API_DEFINITION", - "description": " Lists all the models linked to this event store.", - "canonical": true, - "file": "model_service.list_models.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 67, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListModels", - "fullName": "google.cloud.retail.v2beta.ModelService.ListModels", - "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.ListModelsResponse", - "client": { - "shortName": "ModelServiceClient", - "fullName": "google.cloud.retail.v2beta.ModelServiceClient" - }, - "method": { - "shortName": "ListModels", - "fullName": "google.cloud.retail.v2beta.ModelService.ListModels", - "service": { - "shortName": "ModelService", - "fullName": "google.cloud.retail.v2beta.ModelService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ModelService_UpdateModel_async", - "title": "CatalogService updateModel Sample", - "origin": "API_DEFINITION", - "description": " Update of model metadata. Only fields that currently can be updated are: `filtering_option` and `periodic_tuning_state`. If other values are provided, this API method ignores them.", - "canonical": true, - "file": "model_service.update_model.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateModel", - "fullName": "google.cloud.retail.v2beta.ModelService.UpdateModel", - "async": true, - "parameters": [ - { - "name": "model", - "type": ".google.cloud.retail.v2beta.Model" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.retail.v2beta.Model", - "client": { - "shortName": "ModelServiceClient", - "fullName": "google.cloud.retail.v2beta.ModelServiceClient" - }, - "method": { - "shortName": "UpdateModel", - "fullName": "google.cloud.retail.v2beta.ModelService.UpdateModel", - "service": { - "shortName": "ModelService", - "fullName": "google.cloud.retail.v2beta.ModelService" - } - } - } - }, - { - "regionTag": "retail_v2beta_generated_ModelService_TuneModel_async", - "title": "CatalogService tuneModel Sample", - "origin": "API_DEFINITION", - "description": " Tunes an existing model.", - "canonical": true, - "file": "model_service.tune_model.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 56, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "TuneModel", - "fullName": "google.cloud.retail.v2beta.ModelService.TuneModel", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.longrunning.Operation", - "client": { - "shortName": "ModelServiceClient", - "fullName": "google.cloud.retail.v2beta.ModelServiceClient" - }, - "method": { - "shortName": "TuneModel", - "fullName": "google.cloud.retail.v2beta.ModelService.TuneModel", - "service": { - "shortName": "ModelService", - "fullName": "google.cloud.retail.v2beta.ModelService" - } - } - } - }, - { - "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": 179, - "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": 75, - "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": 60, - "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": 127, - "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": 79, - "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": 70, - "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. 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": 90, - "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 is 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 [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. When inventory is updated with [ProductService.CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] and [ProductService.UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct], the specified inventory field value(s) overwrite any existing value(s) while ignoring the last update time for this field. Furthermore, the last update times for the specified inventory fields are overwritten by the times of the [ProductService.CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] or [ProductService.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 is used. If no inventory fields are set in [SetInventoryRequest.set_mask][google.cloud.retail.v2beta.SetInventoryRequest.set_mask], then any existing inventory information is preserved. Pre-existing inventory information can only be updated with [ProductService.SetInventory][google.cloud.retail.v2beta.ProductService.SetInventory], [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.AddFulfillmentPlaces], and [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces]. The returned [Operation][google.longrunning.Operation]s is obsolete after one day, and the [GetOperation][google.longrunning.Operations.GetOperation] API returns `NOT_FOUND` afterwards. If conflicting updates are issued, the [Operation][google.longrunning.Operation]s associated with the stale updates are not marked as [done][google.longrunning.Operation.done] until they are obsolete.", - "canonical": true, - "file": "product_service.set_inventory.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 123, - "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": " It is recommended to use the [ProductService.AddLocalInventories][google.cloud.retail.v2beta.ProductService.AddLocalInventories] method instead of [ProductService.AddFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.AddFulfillmentPlaces]. [ProductService.AddLocalInventories][google.cloud.retail.v2beta.ProductService.AddLocalInventories] achieves the same results but provides more fine-grained control over ingesting local inventory data. 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 [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. The returned [Operation][google.longrunning.Operation]s will be obsolete after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] API will return NOT_FOUND afterwards. If conflicting updates are issued, the [Operation][google.longrunning.Operation]s associated with the stale updates will not be marked as [done][google.longrunning.Operation.done] until being obsolete.", - "canonical": true, - "file": "product_service.add_fulfillment_places.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 111, - "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": " It is recommended to use the [ProductService.RemoveLocalInventories][google.cloud.retail.v2beta.ProductService.RemoveLocalInventories] method instead of [ProductService.RemoveFulfillmentPlaces][google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces]. [ProductService.RemoveLocalInventories][google.cloud.retail.v2beta.ProductService.RemoveLocalInventories] achieves the same results but provides more fine-grained control over ingesting local inventory data. 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 [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. The returned [Operation][google.longrunning.Operation]s will be obsolete after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] API will return NOT_FOUND afterwards. If conflicting updates are issued, the [Operation][google.longrunning.Operation]s associated with the stale updates will not be marked as [done][google.longrunning.Operation.done] until being obsolete.", - "canonical": true, - "file": "product_service.remove_fulfillment_places.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 107, - "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 [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. Local inventory information can only be modified using this method. [ProductService.CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] and [ProductService.UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct] has no effect on local inventories. The returned [Operation][google.longrunning.Operation]s will be obsolete after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] API will return NOT_FOUND afterwards. If conflicting updates are issued, the [Operation][google.longrunning.Operation]s associated with the stale updates will not be marked as [done][google.longrunning.Operation.done] until being obsolete.", - "canonical": true, - "file": "product_service.add_local_inventories.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 95, - "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 [ProductService.GetProduct][google.cloud.retail.v2beta.ProductService.GetProduct] or [ProductService.ListProducts][google.cloud.retail.v2beta.ProductService.ListProducts]. Local inventory information can only be removed using this method. [ProductService.CreateProduct][google.cloud.retail.v2beta.ProductService.CreateProduct] and [ProductService.UpdateProduct][google.cloud.retail.v2beta.ProductService.UpdateProduct] has no effect on local inventories. The returned [Operation][google.longrunning.Operation]s will be obsolete after 1 day, and [GetOperation][google.longrunning.Operations.GetOperation] API will return NOT_FOUND afterwards. If conflicting updates are issued, the [Operation][google.longrunning.Operation]s associated with the stale updates will not be marked as [done][google.longrunning.Operation.done] until being obsolete.", - "canonical": true, - "file": "product_service.remove_local_inventories.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 80, - "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. Enable Retail Search on Cloud Console before using this feature.", - "canonical": true, - "file": "search_service.search.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 304, - "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" - }, - { - "name": "labels", - "type": "TYPE_MESSAGE[]" - }, - { - "name": "spell_correction_spec", - "type": ".google.cloud.retail.v2beta.SearchRequest.SpellCorrectionSpec" - }, - { - "name": "entity", - "type": "TYPE_STRING" - } - ], - "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": 67, - "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": 54, - "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": 61, - "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": 54, - "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": 67, - "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": 60, - "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": 60, - "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": 66, - "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" - }, - { - "name": "write_async", - "type": "TYPE_BOOL" - } - ], - "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": 85, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CollectUserEvent", - "fullName": "google.cloud.retail.v2beta.UserEventService.CollectUserEvent", - "async": true, - "parameters": [ - { - "name": "prebuilt_rule", - "type": "TYPE_STRING" - }, - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "user_event", - "type": "TYPE_STRING" - }, - { - "name": "uri", - "type": "TYPE_STRING" - }, - { - "name": "ets", - "type": "TYPE_INT64" - }, - { - "name": "raw_json", - "type": "TYPE_STRING" - } - ], - "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": 86, - "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": 64, - "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 are not annotated with detailed product information for products that are missing from the catalog when the user event is ingested. These events are stored as unjoined events with limited usage on training and serving. You can use this method to start a join operation on specified events with the latest version of product catalog. You can also use this method 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": 62, - "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/google-cloud-retail/v2beta/samples/generated/v2beta/user_event_service.collect_user_event.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/user_event_service.collect_user_event.js deleted file mode 100644 index 90657a3b92b..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/user_event_service.collect_user_event.js +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * The prebuilt rule name that can convert a specific type of raw_json. - * For example: "ga4_bq" rule for the GA4 user event schema. - */ - // const prebuiltRule = 'abc123' - /** - * 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 - /** - * An arbitrary serialized JSON string that contains necessary information - * that can comprise a user event. When this field is specified, the - * user_event field will be ignored. Note: line-delimited JSON is not - * supported, a single JSON only. - */ - // const rawJson = 'abc123' - - // 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/google-cloud-retail/v2beta/samples/generated/v2beta/user_event_service.import_user_events.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/user_event_service.import_user_events.js deleted file mode 100644 index 6ace38eb656..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/user_event_service.import_user_events.js +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * 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/google-cloud-retail/v2beta/samples/generated/v2beta/user_event_service.purge_user_events.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/user_event_service.purge_user_events.js deleted file mode 100644 index 82335eaee23..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/user_event_service.purge_user_events.js +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The resource name of the 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/google-cloud-retail/v2beta/samples/generated/v2beta/user_event_service.rejoin_user_events.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/user_event_service.rejoin_user_events.js deleted file mode 100644 index 08e816c0a68..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/user_event_service.rejoin_user_events.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent 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/google-cloud-retail/v2beta/samples/generated/v2beta/user_event_service.write_user_event.js b/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/user_event_service.write_user_event.js deleted file mode 100644 index 2e2222f9d90..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/samples/generated/v2beta/user_event_service.write_user_event.js +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated 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] - /** - * This snippet has been automatically generated and should be regarded as a code template only. - * It will require modifications to work. - * It may require correct/in-range values for request initialization. - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The parent catalog resource name, such as - * `projects/1234/locations/global/catalogs/default_catalog`. - */ - // const parent = 'abc123' - /** - * Required. User event to write. - */ - // const userEvent = {} - /** - * If set to true, the user event will be written asynchronously after - * validation, and the API will respond without waiting for the write. - * Therefore, silent failures can occur even if the API returns success. In - * case of silent failures, error messages can be found in Stackdriver logs. - */ - // const writeAsync = true - - // 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/google-cloud-retail/v2beta/src/index.ts b/owl-bot-staging/google-cloud-retail/v2beta/src/index.ts deleted file mode 100644 index 87d258343ac..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/src/index.ts +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This 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 ModelServiceClient = v2beta.ModelServiceClient; -type ModelServiceClient = v2beta.ModelServiceClient; -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, ModelServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, ServingConfigServiceClient, UserEventServiceClient}; -export default {v2beta, CatalogServiceClient, CompletionServiceClient, ControlServiceClient, ModelServiceClient, PredictionServiceClient, ProductServiceClient, SearchServiceClient, ServingConfigServiceClient, UserEventServiceClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/catalog_service_client.ts b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/catalog_service_client.ts deleted file mode 100644 index 2bf80acd632..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/catalog_service_client.ts +++ /dev/null @@ -1,2304 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/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}; - locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - 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/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new CatalogServiceClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof 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); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - this.locationsClient = new this._gaxModule.LocationsClient( - this._gaxGrpc, - opts - ); - - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - 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}' - ), - modelPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' - ), - 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') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',additional_bindings: [{get: '/v2beta/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2beta/{name=projects/*/locations/*/operations/*}',},{get: '/v2beta/{name=projects/*/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2beta/{name=projects/*/locations/*/catalogs/*}/operations',additional_bindings: [{get: '/v2beta/{name=projects/*/locations/*}/operations',},{get: '/v2beta/{name=projects/*}/operations',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - - this.descriptors.longrunning = { - }; - - // 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 = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.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', 'batchRemoveCatalogAttributes', '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._opts.fallback - ); - - 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 {@link google.cloud.retail.v2beta.Catalog | 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' - ] = this._gaxModule.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 {@link google.protobuf.Empty | 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' - ] = this._gaxModule.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 {@link google.cloud.retail.v2beta.GetDefaultBranchResponse | 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' - ] = this._gaxModule.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 {@link google.cloud.retail.v2beta.CompletionConfig | 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' - ] = this._gaxModule.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 {@link google.cloud.retail.v2beta.CompletionConfig | 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' - ] = this._gaxModule.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 {@link google.cloud.retail.v2beta.AttributesConfig | 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' - ] = this._gaxModule.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 {@link google.cloud.retail.v2beta.AttributesConfig | 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' - ] = this._gaxModule.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 {@link google.cloud.retail.v2beta.AttributesConfig | 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' - ] = this._gaxModule.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 {@link google.cloud.retail.v2beta.AttributesConfig | 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'attributes_config': request.attributesConfig ?? '', - }); - this.initialize(); - return this.innerApiCalls.removeCatalogAttribute(request, options, callback); - } -/** - * Removes all specified - * {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute}s from the - * {@link google.cloud.retail.v2beta.AttributesConfig|AttributesConfig}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.attributesConfig - * Required. The attributes config resource shared by all catalog attributes - * being deleted. Format: - * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/attributesConfig` - * @param {string[]} request.attributeKeys - * Required. The attribute name keys of the - * {@link google.cloud.retail.v2beta.CatalogAttribute|CatalogAttribute}s to delete. - * A maximum of 1000 catalog attributes can be deleted in a batch. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse | BatchRemoveCatalogAttributesResponse}. - * Please see 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.batch_remove_catalog_attributes.js - * region_tag:retail_v2beta_generated_CatalogService_BatchRemoveCatalogAttributes_async - */ - batchRemoveCatalogAttributes( - request?: protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesResponse, - protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesRequest|undefined, {}|undefined - ]>; - batchRemoveCatalogAttributes( - request: protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesResponse, - protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesRequest|null|undefined, - {}|null|undefined>): void; - batchRemoveCatalogAttributes( - request: protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesResponse, - protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesRequest|null|undefined, - {}|null|undefined>): void; - batchRemoveCatalogAttributes( - request?: protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesResponse, - protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesResponse, - protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesResponse, - protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'attributes_config': request.attributesConfig ?? '', - }); - this.initialize(); - return this.innerApiCalls.batchRemoveCatalogAttributes(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 {@link google.cloud.retail.v2beta.AttributesConfig | 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' - ] = this._gaxModule.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 {@link google.cloud.retail.v2beta.Catalog | 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' - ] = this._gaxModule.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 {@link google.cloud.retail.v2beta.Catalog | 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' - ] = this._gaxModule.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 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 - * {@link google.cloud.retail.v2beta.Catalog | 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' - ] = this._gaxModule.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 {}, - callSettings - ) as AsyncIterable; - } -/** - * Gets information about a location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Resource name for the location. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * ``` - * const [response] = await client.getLocation(request); - * ``` - */ - getLocation( - request: LocationProtos.google.cloud.location.IGetLocationRequest, - options?: - | gax.CallOptions - | Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - > - ): Promise { - return this.locationsClient.getLocation(request, options, callback); - } - -/** - * Lists information about the supported locations for this service. Returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The resource that owns the locations collection, if applicable. - * @param {string} request.filter - * The standard list filter. - * @param {number} request.pageSize - * The standard list page size. - * @param {string} request.pageToken - * The standard list page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example - * ``` - * const iterable = client.listLocationsAsync(request); - * for await (const response of iterable) { - * // process response - * } - * ``` - */ - listLocationsAsync( - request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions - ): AsyncIterable { - return this.locationsClient.listLocationsAsync(request, options); - } - -/** - * Gets the latest state of a long-running operation. Clients can use this - * method to poll the operation result at intervals as recommended by the API - * service. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error, ?Object)=} callback - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * const name = ''; - * const [response] = await client.getOperation({name}); - * // doThingsWith(response) - * ``` - */ - getOperation( - request: protos.google.longrunning.GetOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - > - ): Promise<[protos.google.longrunning.Operation]> { - return this.operationsClient.getOperation(request, options, callback); - } - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. - * - * For-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation collection. - * @param {string} request.filter - The standard list filter. - * @param {number=} request.pageSize - - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @returns {Object} - * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * for await (const response of client.listOperationsAsync(request)); - * // doThingsWith(response) - * ``` - */ - listOperationsAsync( - request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions - ): AsyncIterable { - return this.operationsClient.listOperationsAsync(request, options); - } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * {@link Operations.GetOperation} or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an {@link Operation.error} value with a {@link google.rpc.Status.code} of - * 1, corresponding to `Code.CANCELLED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be cancelled. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.cancelOperation({name: ''}); - * ``` - */ - cancelOperation( - request: protos.google.longrunning.CancelOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.CancelOperationRequest, - {} | undefined | null - >, - callback?: Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - > - ): Promise { - return this.operationsClient.cancelOperation(request, options, callback); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be deleted. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.deleteOperation({name: ''}); - * ``` - */ - deleteOperation( - request: protos.google.longrunning.DeleteOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - > - ): Promise { - return this.operationsClient.deleteOperation(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified 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 model resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} model - * @returns {string} Resource name string. - */ - modelPath(project:string,location:string,catalog:string,model:string) { - return this.pathTemplates.modelPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - model: model, - }); - } - - /** - * Parse the project from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the project. - */ - matchProjectFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).project; - } - - /** - * Parse the location from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the location. - */ - matchLocationFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).location; - } - - /** - * Parse the catalog from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).catalog; - } - - /** - * Parse the model from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the model. - */ - matchModelFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).model; - } - - /** - * 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(); - this.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/catalog_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/catalog_service_client_config.json deleted file mode 100644 index 3554c7046eb..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/catalog_service_client_config.json +++ /dev/null @@ -1,95 +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" - }, - "BatchRemoveCatalogAttributes": { - "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/google-cloud-retail/v2beta/src/v2beta/catalog_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/catalog_service_proto_list.json deleted file mode 100644 index ce2a33ebd29..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/catalog_service_proto_list.json +++ /dev/null @@ -1,22 +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/model.proto", - "../../protos/google/cloud/retail/v2beta/model_service.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/google-cloud-retail/v2beta/src/v2beta/completion_service_client.ts b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/completion_service_client.ts deleted file mode 100644 index 12516895121..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/completion_service_client.ts +++ /dev/null @@ -1,1294 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, LocationsClient, LocationProtos} 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'; -const version = require('../../../package.json').version; - -/** - * Autocomplete service for retail. - * - * This feature is only available for users who have Retail Search enabled. - * 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}; - locationsClient: LocationsClient; - 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/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new CompletionServiceClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof 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); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - this.locationsClient = new this._gaxModule.LocationsClient( - this._gaxGrpc, - opts - ); - - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - 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}' - ), - modelPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' - ), - 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. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',additional_bindings: [{get: '/v2beta/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2beta/{name=projects/*/locations/*/operations/*}',},{get: '/v2beta/{name=projects/*/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2beta/{name=projects/*/locations/*/catalogs/*}/operations',additional_bindings: [{get: '/v2beta/{name=projects/*/locations/*}/operations',},{get: '/v2beta/{name=projects/*}/operations',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).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 = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.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._opts.fallback - ); - - 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. - * 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 - * Note that this field applies for `user-data` dataset only. For requests - * with `cloud-retail` dataset, setting this field has no effect. - * - * 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. We recommend that you - * leave this field empty. - * - * It can 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 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 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 {string} request.entity - * The entity for customers that may run multiple different entities, domains, - * sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, - * `google.com`, `youtube.com`, etc. - * If this is set, it should be exactly matched with - * {@link google.cloud.retail.v2beta.UserEvent.entity|UserEvent.entity} to get - * per-entity autocomplete results. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.retail.v2beta.CompleteQueryResponse | 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' - ] = this._gaxModule.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. - * 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 is sent to - * specified Pub/Sub topic. The message data is 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' - ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.importCompletionData, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Gets information about a location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Resource name for the location. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * ``` - * const [response] = await client.getLocation(request); - * ``` - */ - getLocation( - request: LocationProtos.google.cloud.location.IGetLocationRequest, - options?: - | gax.CallOptions - | Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - > - ): Promise { - return this.locationsClient.getLocation(request, options, callback); - } - -/** - * Lists information about the supported locations for this service. Returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The resource that owns the locations collection, if applicable. - * @param {string} request.filter - * The standard list filter. - * @param {number} request.pageSize - * The standard list page size. - * @param {string} request.pageToken - * The standard list page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example - * ``` - * const iterable = client.listLocationsAsync(request); - * for await (const response of iterable) { - * // process response - * } - * ``` - */ - listLocationsAsync( - request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions - ): AsyncIterable { - return this.locationsClient.listLocationsAsync(request, options); - } - -/** - * Gets the latest state of a long-running operation. Clients can use this - * method to poll the operation result at intervals as recommended by the API - * service. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error, ?Object)=} callback - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * const name = ''; - * const [response] = await client.getOperation({name}); - * // doThingsWith(response) - * ``` - */ - getOperation( - request: protos.google.longrunning.GetOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - > - ): Promise<[protos.google.longrunning.Operation]> { - return this.operationsClient.getOperation(request, options, callback); - } - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. - * - * For-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation collection. - * @param {string} request.filter - The standard list filter. - * @param {number=} request.pageSize - - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @returns {Object} - * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * for await (const response of client.listOperationsAsync(request)); - * // doThingsWith(response) - * ``` - */ - listOperationsAsync( - request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions - ): AsyncIterable { - return this.operationsClient.listOperationsAsync(request, options); - } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * {@link Operations.GetOperation} or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an {@link Operation.error} value with a {@link google.rpc.Status.code} of - * 1, corresponding to `Code.CANCELLED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be cancelled. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.cancelOperation({name: ''}); - * ``` - */ - cancelOperation( - request: protos.google.longrunning.CancelOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.CancelOperationRequest, - {} | undefined | null - >, - callback?: Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - > - ): Promise { - return this.operationsClient.cancelOperation(request, options, callback); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be deleted. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.deleteOperation({name: ''}); - * ``` - */ - deleteOperation( - request: protos.google.longrunning.DeleteOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - > - ): Promise { - return this.operationsClient.deleteOperation(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified 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 model resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} model - * @returns {string} Resource name string. - */ - modelPath(project:string,location:string,catalog:string,model:string) { - return this.pathTemplates.modelPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - model: model, - }); - } - - /** - * Parse the project from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the project. - */ - matchProjectFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).project; - } - - /** - * Parse the location from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the location. - */ - matchLocationFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).location; - } - - /** - * Parse the catalog from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).catalog; - } - - /** - * Parse the model from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the model. - */ - matchModelFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).model; - } - - /** - * 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.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/completion_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/completion_service_client_config.json deleted file mode 100644 index 1865fe66ef1..00000000000 --- a/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2beta/src/v2beta/completion_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/completion_service_proto_list.json deleted file mode 100644 index ce2a33ebd29..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/completion_service_proto_list.json +++ /dev/null @@ -1,22 +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/model.proto", - "../../protos/google/cloud/retail/v2beta/model_service.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/google-cloud-retail/v2beta/src/v2beta/control_service_client.ts b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/control_service_client.ts deleted file mode 100644 index 96b60e56165..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/control_service_client.ts +++ /dev/null @@ -1,1556 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/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}; - locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - 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/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new ControlServiceClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof 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); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - this.locationsClient = new this._gaxModule.LocationsClient( - this._gaxGrpc, - opts - ); - - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - 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}' - ), - modelPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' - ), - 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') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',additional_bindings: [{get: '/v2beta/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2beta/{name=projects/*/locations/*/operations/*}',},{get: '/v2beta/{name=projects/*/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2beta/{name=projects/*/locations/*/catalogs/*}/operations',additional_bindings: [{get: '/v2beta/{name=projects/*/locations/*}/operations',},{get: '/v2beta/{name=projects/*}/operations',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - - this.descriptors.longrunning = { - }; - - // 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 = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.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._opts.fallback - ); - - 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 {@link google.cloud.retail.v2beta.Control | 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' - ] = this._gaxModule.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 {@link google.protobuf.Empty | 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' - ] = this._gaxModule.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 update 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 {@link google.cloud.retail.v2beta.Control | 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' - ] = this._gaxModule.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 get. 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 {@link google.cloud.retail.v2beta.Control | 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getControl(request, options, callback); - } - - /** - * Lists all Controls by their parent - * {@link google.cloud.retail.v2beta.Catalog|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 {@link google.cloud.retail.v2beta.Control | 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' - ] = this._gaxModule.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 {@link google.cloud.retail.v2beta.Control | 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' - ] = this._gaxModule.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 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 - * {@link google.cloud.retail.v2beta.Control | 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' - ] = this._gaxModule.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 {}, - callSettings - ) as AsyncIterable; - } -/** - * Gets information about a location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Resource name for the location. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * ``` - * const [response] = await client.getLocation(request); - * ``` - */ - getLocation( - request: LocationProtos.google.cloud.location.IGetLocationRequest, - options?: - | gax.CallOptions - | Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - > - ): Promise { - return this.locationsClient.getLocation(request, options, callback); - } - -/** - * Lists information about the supported locations for this service. Returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The resource that owns the locations collection, if applicable. - * @param {string} request.filter - * The standard list filter. - * @param {number} request.pageSize - * The standard list page size. - * @param {string} request.pageToken - * The standard list page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example - * ``` - * const iterable = client.listLocationsAsync(request); - * for await (const response of iterable) { - * // process response - * } - * ``` - */ - listLocationsAsync( - request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions - ): AsyncIterable { - return this.locationsClient.listLocationsAsync(request, options); - } - -/** - * Gets the latest state of a long-running operation. Clients can use this - * method to poll the operation result at intervals as recommended by the API - * service. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error, ?Object)=} callback - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * const name = ''; - * const [response] = await client.getOperation({name}); - * // doThingsWith(response) - * ``` - */ - getOperation( - request: protos.google.longrunning.GetOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - > - ): Promise<[protos.google.longrunning.Operation]> { - return this.operationsClient.getOperation(request, options, callback); - } - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. - * - * For-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation collection. - * @param {string} request.filter - The standard list filter. - * @param {number=} request.pageSize - - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @returns {Object} - * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * for await (const response of client.listOperationsAsync(request)); - * // doThingsWith(response) - * ``` - */ - listOperationsAsync( - request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions - ): AsyncIterable { - return this.operationsClient.listOperationsAsync(request, options); - } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * {@link Operations.GetOperation} or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an {@link Operation.error} value with a {@link google.rpc.Status.code} of - * 1, corresponding to `Code.CANCELLED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be cancelled. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.cancelOperation({name: ''}); - * ``` - */ - cancelOperation( - request: protos.google.longrunning.CancelOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.CancelOperationRequest, - {} | undefined | null - >, - callback?: Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - > - ): Promise { - return this.operationsClient.cancelOperation(request, options, callback); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be deleted. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.deleteOperation({name: ''}); - * ``` - */ - deleteOperation( - request: protos.google.longrunning.DeleteOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - > - ): Promise { - return this.operationsClient.deleteOperation(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified 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 model resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} model - * @returns {string} Resource name string. - */ - modelPath(project:string,location:string,catalog:string,model:string) { - return this.pathTemplates.modelPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - model: model, - }); - } - - /** - * Parse the project from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the project. - */ - matchProjectFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).project; - } - - /** - * Parse the location from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the location. - */ - matchLocationFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).location; - } - - /** - * Parse the catalog from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).catalog; - } - - /** - * Parse the model from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the model. - */ - matchModelFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).model; - } - - /** - * 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(); - this.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/control_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/control_service_client_config.json deleted file mode 100644 index b7572aeb833..00000000000 --- a/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2beta/src/v2beta/control_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/control_service_proto_list.json deleted file mode 100644 index ce2a33ebd29..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/control_service_proto_list.json +++ /dev/null @@ -1,22 +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/model.proto", - "../../protos/google/cloud/retail/v2beta/model_service.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/google-cloud-retail/v2beta/src/v2beta/gapic_metadata.json b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/gapic_metadata.json deleted file mode 100644 index 9fa0d1c4170..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/gapic_metadata.json +++ /dev/null @@ -1,679 +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" - ] - }, - "BatchRemoveCatalogAttributes": { - "methods": [ - "batchRemoveCatalogAttributes" - ] - }, - "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" - ] - }, - "BatchRemoveCatalogAttributes": { - "methods": [ - "batchRemoveCatalogAttributes" - ] - }, - "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" - ] - } - } - } - } - }, - "ModelService": { - "clients": { - "grpc": { - "libraryClient": "ModelServiceClient", - "rpcs": { - "GetModel": { - "methods": [ - "getModel" - ] - }, - "PauseModel": { - "methods": [ - "pauseModel" - ] - }, - "ResumeModel": { - "methods": [ - "resumeModel" - ] - }, - "DeleteModel": { - "methods": [ - "deleteModel" - ] - }, - "UpdateModel": { - "methods": [ - "updateModel" - ] - }, - "CreateModel": { - "methods": [ - "createModel" - ] - }, - "TuneModel": { - "methods": [ - "tuneModel" - ] - }, - "ListModels": { - "methods": [ - "listModels", - "listModelsStream", - "listModelsAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "ModelServiceClient", - "rpcs": { - "GetModel": { - "methods": [ - "getModel" - ] - }, - "PauseModel": { - "methods": [ - "pauseModel" - ] - }, - "ResumeModel": { - "methods": [ - "resumeModel" - ] - }, - "DeleteModel": { - "methods": [ - "deleteModel" - ] - }, - "UpdateModel": { - "methods": [ - "updateModel" - ] - }, - "CreateModel": { - "methods": [ - "createModel" - ] - }, - "TuneModel": { - "methods": [ - "tuneModel" - ] - }, - "ListModels": { - "methods": [ - "listModels", - "listModelsStream", - "listModelsAsync" - ] - } - } - } - } - }, - "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/google-cloud-retail/v2beta/src/v2beta/index.ts b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/index.ts deleted file mode 100644 index 24ad5baba84..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/index.ts +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** 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 {ModelServiceClient} from './model_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/google-cloud-retail/v2beta/src/v2beta/model_service_client.ts b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/model_service_client.ts deleted file mode 100644 index 22896921fbe..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/model_service_client.ts +++ /dev/null @@ -1,1812 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v2beta/model_service_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './model_service_client_config.json'; -const version = require('../../../package.json').version; - -/** - * Service for performing CRUD operations on models. - * Recommendation models contain all the metadata necessary to generate a set of - * models for the `Predict()` API. A model is queried - * indirectly via a ServingConfig, which associates a model with a - * given Placement (e.g. Frequently Bought Together on Home Page). - * - * This service allows you to do the following: - * - * * Initiate training of a model. - * * Pause training of an existing model. - * * List all the available models along with their metadata. - * * Control their tuning schedule. - * @class - * @memberof v2beta - */ -export class ModelServiceClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - modelServiceStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of ModelServiceClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new ModelServiceClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof ModelServiceClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - this.locationsClient = new this._gaxModule.LocationsClient( - this._gaxGrpc, - opts - ); - - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - 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}' - ), - modelPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' - ), - 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 = { - listModels: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'models') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',additional_bindings: [{get: '/v2beta/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2beta/{name=projects/*/locations/*/operations/*}',},{get: '/v2beta/{name=projects/*/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2beta/{name=projects/*/locations/*/catalogs/*}/operations',additional_bindings: [{get: '/v2beta/{name=projects/*/locations/*}/operations',},{get: '/v2beta/{name=projects/*}/operations',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - const createModelResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2beta.Model') as gax.protobuf.Type; - const createModelMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2beta.CreateModelMetadata') as gax.protobuf.Type; - const tuneModelResponse = protoFilesRoot.lookup( - '.google.cloud.retail.v2beta.TuneModelResponse') as gax.protobuf.Type; - const tuneModelMetadata = protoFilesRoot.lookup( - '.google.cloud.retail.v2beta.TuneModelMetadata') as gax.protobuf.Type; - - this.descriptors.longrunning = { - createModel: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createModelResponse.decode.bind(createModelResponse), - createModelMetadata.decode.bind(createModelMetadata)), - tuneModel: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - tuneModelResponse.decode.bind(tuneModelResponse), - tuneModelMetadata.decode.bind(tuneModelMetadata)) - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.retail.v2beta.ModelService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.modelServiceStub) { - return this.modelServiceStub; - } - - // Put together the "service stub" for - // google.cloud.retail.v2beta.ModelService. - this.modelServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.retail.v2beta.ModelService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.retail.v2beta.ModelService, - 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 modelServiceStubMethods = - ['createModel', 'getModel', 'pauseModel', 'resumeModel', 'deleteModel', 'listModels', 'updateModel', 'tuneModel']; - for (const methodName of modelServiceStubMethods) { - const callPromise = this.modelServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - this.descriptors.longrunning[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor, - this._opts.fallback - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.modelServiceStub; - } - - /** - * 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 -- - // ------------------- -/** - * Gets a model. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the - * {@link google.cloud.retail.v2beta.Model|Model} to get. Format: - * `projects/{project_number}/locations/{location_id}/catalogs/{catalog}/models/{model_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 {@link google.cloud.retail.v2beta.Model | Model}. - * Please see 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/model_service.get_model.js - * region_tag:retail_v2beta_generated_ModelService_GetModel_async - */ - getModel( - request?: protos.google.cloud.retail.v2beta.IGetModelRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IModel, - protos.google.cloud.retail.v2beta.IGetModelRequest|undefined, {}|undefined - ]>; - getModel( - request: protos.google.cloud.retail.v2beta.IGetModelRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.IModel, - protos.google.cloud.retail.v2beta.IGetModelRequest|null|undefined, - {}|null|undefined>): void; - getModel( - request: protos.google.cloud.retail.v2beta.IGetModelRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.IModel, - protos.google.cloud.retail.v2beta.IGetModelRequest|null|undefined, - {}|null|undefined>): void; - getModel( - request?: protos.google.cloud.retail.v2beta.IGetModelRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.IModel, - protos.google.cloud.retail.v2beta.IGetModelRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.IModel, - protos.google.cloud.retail.v2beta.IGetModelRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.IModel, - protos.google.cloud.retail.v2beta.IGetModelRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.getModel(request, options, callback); - } -/** - * Pauses the training of an existing model. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the model to pause. - * Format: - * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_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 {@link google.cloud.retail.v2beta.Model | Model}. - * Please see 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/model_service.pause_model.js - * region_tag:retail_v2beta_generated_ModelService_PauseModel_async - */ - pauseModel( - request?: protos.google.cloud.retail.v2beta.IPauseModelRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IModel, - protos.google.cloud.retail.v2beta.IPauseModelRequest|undefined, {}|undefined - ]>; - pauseModel( - request: protos.google.cloud.retail.v2beta.IPauseModelRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.IModel, - protos.google.cloud.retail.v2beta.IPauseModelRequest|null|undefined, - {}|null|undefined>): void; - pauseModel( - request: protos.google.cloud.retail.v2beta.IPauseModelRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.IModel, - protos.google.cloud.retail.v2beta.IPauseModelRequest|null|undefined, - {}|null|undefined>): void; - pauseModel( - request?: protos.google.cloud.retail.v2beta.IPauseModelRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.IModel, - protos.google.cloud.retail.v2beta.IPauseModelRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.IModel, - protos.google.cloud.retail.v2beta.IPauseModelRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.IModel, - protos.google.cloud.retail.v2beta.IPauseModelRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.pauseModel(request, options, callback); - } -/** - * Resumes the training of an existing model. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the model to resume. - * Format: - * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_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 {@link google.cloud.retail.v2beta.Model | Model}. - * Please see 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/model_service.resume_model.js - * region_tag:retail_v2beta_generated_ModelService_ResumeModel_async - */ - resumeModel( - request?: protos.google.cloud.retail.v2beta.IResumeModelRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IModel, - protos.google.cloud.retail.v2beta.IResumeModelRequest|undefined, {}|undefined - ]>; - resumeModel( - request: protos.google.cloud.retail.v2beta.IResumeModelRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.IModel, - protos.google.cloud.retail.v2beta.IResumeModelRequest|null|undefined, - {}|null|undefined>): void; - resumeModel( - request: protos.google.cloud.retail.v2beta.IResumeModelRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.IModel, - protos.google.cloud.retail.v2beta.IResumeModelRequest|null|undefined, - {}|null|undefined>): void; - resumeModel( - request?: protos.google.cloud.retail.v2beta.IResumeModelRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.IModel, - protos.google.cloud.retail.v2beta.IResumeModelRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.IModel, - protos.google.cloud.retail.v2beta.IResumeModelRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.IModel, - protos.google.cloud.retail.v2beta.IResumeModelRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.resumeModel(request, options, callback); - } -/** - * Deletes an existing model. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the - * {@link google.cloud.retail.v2beta.Model|Model} to delete. Format: - * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_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 {@link google.protobuf.Empty | 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/model_service.delete_model.js - * region_tag:retail_v2beta_generated_ModelService_DeleteModel_async - */ - deleteModel( - request?: protos.google.cloud.retail.v2beta.IDeleteModelRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.IDeleteModelRequest|undefined, {}|undefined - ]>; - deleteModel( - request: protos.google.cloud.retail.v2beta.IDeleteModelRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.IDeleteModelRequest|null|undefined, - {}|null|undefined>): void; - deleteModel( - request: protos.google.cloud.retail.v2beta.IDeleteModelRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.IDeleteModelRequest|null|undefined, - {}|null|undefined>): void; - deleteModel( - request?: protos.google.cloud.retail.v2beta.IDeleteModelRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.IDeleteModelRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.IDeleteModelRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.retail.v2beta.IDeleteModelRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.deleteModel(request, options, callback); - } -/** - * Update of model metadata. Only fields that - * currently can be updated are: `filtering_option` and - * `periodic_tuning_state`. - * If other values are provided, this API method ignores them. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.retail.v2beta.Model} request.model - * Required. The body of the updated - * {@link google.cloud.retail.v2beta.Model|Model}. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Indicates which fields in the provided 'model' to - * update. If not set, by default updates all fields. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.retail.v2beta.Model | Model}. - * Please see 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/model_service.update_model.js - * region_tag:retail_v2beta_generated_ModelService_UpdateModel_async - */ - updateModel( - request?: protos.google.cloud.retail.v2beta.IUpdateModelRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IModel, - protos.google.cloud.retail.v2beta.IUpdateModelRequest|undefined, {}|undefined - ]>; - updateModel( - request: protos.google.cloud.retail.v2beta.IUpdateModelRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.retail.v2beta.IModel, - protos.google.cloud.retail.v2beta.IUpdateModelRequest|null|undefined, - {}|null|undefined>): void; - updateModel( - request: protos.google.cloud.retail.v2beta.IUpdateModelRequest, - callback: Callback< - protos.google.cloud.retail.v2beta.IModel, - protos.google.cloud.retail.v2beta.IUpdateModelRequest|null|undefined, - {}|null|undefined>): void; - updateModel( - request?: protos.google.cloud.retail.v2beta.IUpdateModelRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.retail.v2beta.IModel, - protos.google.cloud.retail.v2beta.IUpdateModelRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.retail.v2beta.IModel, - protos.google.cloud.retail.v2beta.IUpdateModelRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.retail.v2beta.IModel, - protos.google.cloud.retail.v2beta.IUpdateModelRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'model.name': request.model!.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.updateModel(request, options, callback); - } - -/** - * Creates a new model. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource under which to create the model. Format: - * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}` - * @param {google.cloud.retail.v2beta.Model} request.model - * Required. The payload of the {@link google.cloud.retail.v2beta.Model|Model} to - * create. - * @param {boolean} [request.dryRun] - * Optional. Whether to run a dry run to validate the request (without - * actually creating the model). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [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/model_service.create_model.js - * region_tag:retail_v2beta_generated_ModelService_CreateModel_async - */ - createModel( - request?: protos.google.cloud.retail.v2beta.ICreateModelRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - createModel( - request: protos.google.cloud.retail.v2beta.ICreateModelRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createModel( - request: protos.google.cloud.retail.v2beta.ICreateModelRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - createModel( - request?: protos.google.cloud.retail.v2beta.ICreateModelRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.createModel(request, options, callback); - } -/** - * Check the status of the long running operation returned by `createModel()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [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/model_service.create_model.js - * region_tag:retail_v2beta_generated_ModelService_CreateModel_async - */ - async checkCreateModelProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createModel, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Tunes an existing model. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the model to tune. - * Format: - * `projects/{project_number}/locations/{location_id}/catalogs/{catalog_id}/models/{model_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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [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/model_service.tune_model.js - * region_tag:retail_v2beta_generated_ModelService_TuneModel_async - */ - tuneModel( - request?: protos.google.cloud.retail.v2beta.ITuneModelRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; - tuneModel( - request: protos.google.cloud.retail.v2beta.ITuneModelRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - tuneModel( - request: protos.google.cloud.retail.v2beta.ITuneModelRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; - tuneModel( - request?: protos.google.cloud.retail.v2beta.ITuneModelRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); - this.initialize(); - return this.innerApiCalls.tuneModel(request, options, callback); - } -/** - * Check the status of the long running operation returned by `tuneModel()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [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/model_service.tune_model.js - * region_tag:retail_v2beta_generated_ModelService_TuneModel_async - */ - async checkTuneModelProgress(name: string): Promise>{ - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.tuneModel, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists all the models linked to this event store. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent for which to list models. - * 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 `ListModels` - * 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 {@link google.cloud.retail.v2beta.Model | Model}. - * 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 `listModelsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listModels( - request?: protos.google.cloud.retail.v2beta.IListModelsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.retail.v2beta.IModel[], - protos.google.cloud.retail.v2beta.IListModelsRequest|null, - protos.google.cloud.retail.v2beta.IListModelsResponse - ]>; - listModels( - request: protos.google.cloud.retail.v2beta.IListModelsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.retail.v2beta.IListModelsRequest, - protos.google.cloud.retail.v2beta.IListModelsResponse|null|undefined, - protos.google.cloud.retail.v2beta.IModel>): void; - listModels( - request: protos.google.cloud.retail.v2beta.IListModelsRequest, - callback: PaginationCallback< - protos.google.cloud.retail.v2beta.IListModelsRequest, - protos.google.cloud.retail.v2beta.IListModelsResponse|null|undefined, - protos.google.cloud.retail.v2beta.IModel>): void; - listModels( - request?: protos.google.cloud.retail.v2beta.IListModelsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.retail.v2beta.IListModelsRequest, - protos.google.cloud.retail.v2beta.IListModelsResponse|null|undefined, - protos.google.cloud.retail.v2beta.IModel>, - callback?: PaginationCallback< - protos.google.cloud.retail.v2beta.IListModelsRequest, - protos.google.cloud.retail.v2beta.IListModelsResponse|null|undefined, - protos.google.cloud.retail.v2beta.IModel>): - Promise<[ - protos.google.cloud.retail.v2beta.IModel[], - protos.google.cloud.retail.v2beta.IListModelsRequest|null, - protos.google.cloud.retail.v2beta.IListModelsResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listModels(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 for which to list models. - * 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 `ListModels` - * 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 {@link google.cloud.retail.v2beta.Model | Model} 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 `listModelsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listModelsStream( - request?: protos.google.cloud.retail.v2beta.IListModelsRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listModels']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listModels.createStream( - this.innerApiCalls.listModels as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listModels`, 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 for which to list models. - * 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 `ListModels` - * 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 - * {@link google.cloud.retail.v2beta.Model | Model}. 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/model_service.list_models.js - * region_tag:retail_v2beta_generated_ModelService_ListModels_async - */ - listModelsAsync( - request?: protos.google.cloud.retail.v2beta.IListModelsRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listModels']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listModels.asyncIterate( - this.innerApiCalls['listModels'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } -/** - * Gets information about a location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Resource name for the location. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * ``` - * const [response] = await client.getLocation(request); - * ``` - */ - getLocation( - request: LocationProtos.google.cloud.location.IGetLocationRequest, - options?: - | gax.CallOptions - | Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - > - ): Promise { - return this.locationsClient.getLocation(request, options, callback); - } - -/** - * Lists information about the supported locations for this service. Returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The resource that owns the locations collection, if applicable. - * @param {string} request.filter - * The standard list filter. - * @param {number} request.pageSize - * The standard list page size. - * @param {string} request.pageToken - * The standard list page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example - * ``` - * const iterable = client.listLocationsAsync(request); - * for await (const response of iterable) { - * // process response - * } - * ``` - */ - listLocationsAsync( - request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions - ): AsyncIterable { - return this.locationsClient.listLocationsAsync(request, options); - } - -/** - * Gets the latest state of a long-running operation. Clients can use this - * method to poll the operation result at intervals as recommended by the API - * service. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error, ?Object)=} callback - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * const name = ''; - * const [response] = await client.getOperation({name}); - * // doThingsWith(response) - * ``` - */ - getOperation( - request: protos.google.longrunning.GetOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - > - ): Promise<[protos.google.longrunning.Operation]> { - return this.operationsClient.getOperation(request, options, callback); - } - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. - * - * For-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation collection. - * @param {string} request.filter - The standard list filter. - * @param {number=} request.pageSize - - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @returns {Object} - * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * for await (const response of client.listOperationsAsync(request)); - * // doThingsWith(response) - * ``` - */ - listOperationsAsync( - request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions - ): AsyncIterable { - return this.operationsClient.listOperationsAsync(request, options); - } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * {@link Operations.GetOperation} or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an {@link Operation.error} value with a {@link google.rpc.Status.code} of - * 1, corresponding to `Code.CANCELLED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be cancelled. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.cancelOperation({name: ''}); - * ``` - */ - cancelOperation( - request: protos.google.longrunning.CancelOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.CancelOperationRequest, - {} | undefined | null - >, - callback?: Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - > - ): Promise { - return this.operationsClient.cancelOperation(request, options, callback); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be deleted. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.deleteOperation({name: ''}); - * ``` - */ - deleteOperation( - request: protos.google.longrunning.DeleteOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - > - ): Promise { - return this.operationsClient.deleteOperation(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified 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 model resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} model - * @returns {string} Resource name string. - */ - modelPath(project:string,location:string,catalog:string,model:string) { - return this.pathTemplates.modelPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - model: model, - }); - } - - /** - * Parse the project from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the project. - */ - matchProjectFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).project; - } - - /** - * Parse the location from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the location. - */ - matchLocationFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).location; - } - - /** - * Parse the catalog from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).catalog; - } - - /** - * Parse the model from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the model. - */ - matchModelFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).model; - } - - /** - * 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.modelServiceStub && !this._terminated) { - return this.modelServiceStub.then(stub => { - this._terminated = true; - stub.close(); - this.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/model_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/model_service_client_config.json deleted file mode 100644 index 49578702c95..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/model_service_client_config.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "interfaces": { - "google.cloud.retail.v2beta.ModelService": { - "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": { - "CreateModel": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetModel": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "PauseModel": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ResumeModel": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteModel": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "ListModels": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UpdateModel": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "TuneModel": { - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/model_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/model_service_proto_list.json deleted file mode 100644 index ce2a33ebd29..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/model_service_proto_list.json +++ /dev/null @@ -1,22 +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/model.proto", - "../../protos/google/cloud/retail/v2beta/model_service.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/google-cloud-retail/v2beta/src/v2beta/prediction_service_client.ts b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/prediction_service_client.ts deleted file mode 100644 index 1a8829046d1..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/prediction_service_client.ts +++ /dev/null @@ -1,1226 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LocationsClient, LocationProtos} 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}; - locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - 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/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new PredictionServiceClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof 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); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - this.locationsClient = new this._gaxModule.LocationsClient( - this._gaxGrpc, - opts - ); - - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - 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}' - ), - modelPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' - ), - 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. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',additional_bindings: [{get: '/v2beta/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2beta/{name=projects/*/locations/*/operations/*}',},{get: '/v2beta/{name=projects/*/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2beta/{name=projects/*/locations/*/catalogs/*}/operations',additional_bindings: [{get: '/v2beta/{name=projects/*/locations/*}/operations',},{get: '/v2beta/{name=projects/*}/operations',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - - this.descriptors.longrunning = { - }; - - // 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 = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.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._opts.fallback - ); - - 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: - * `{placement=projects/* /locations/global/catalogs/default_catalog/servingConfigs/*}` - * or - * `{placement=projects/* /locations/global/catalogs/default_catalog/placements/*}`. - * We recommend using the `servingConfigs` resource. `placements` is a legacy - * resource. - * The ID of the Recommendations AI serving config or placement. - * Before you can request predictions from your model, you must create at - * least one serving config or placement for it. For more information, see - * [Manage serving configs] - * (https://cloud.google.com/retail/docs/manage-configs). - * - * The full list of available serving configs can be seen at - * https://console.cloud.google.com/ai/retail/catalogs/default_catalog/configs - * @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. - * - * Don't set - * {@link google.cloud.retail.v2beta.UserEvent.visitor_id|UserEvent.visitor_id} or - * {@link google.cloud.retail.v2beta.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.v2beta.UserEvent.visitor_id|UserEvent.visitor_id} to - * a random unique ID and leave - * {@link google.cloud.retail.v2beta.UserInfo.user_id|UserInfo.user_id} unset. - * @param {number} request.pageSize - * Maximum number of results to return. 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 - * This field is not used; leave it unset. - * @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 *no* - * results. If instead you want empty result sets to return generic - * (unfiltered) popular products, set `strictFiltering` to False in - * `PredictRequest.params`. Note that the API will never return items with - * storageStatus of "EXPIRED" or "DELETED" regardless of filter choices. - * - * If `filterSyntaxV2` is set to true under the `params` field, then - * attribute-based expressions are expected instead of the above described - * tag-based syntax. Examples: - * - * * (colors: ANY("Red", "Blue")) AND NOT (categories: ANY("Phones")) - * * (availability: ANY("IN_STOCK")) AND - * (colors: ANY("Red") OR categories: ANY("Phones")) - * - * For more information, see - * [Filter recommendations](https://cloud.google.com/retail/docs/filter-recs). - * @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 a 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. - * * `filterSyntaxV2`: Boolean. False by default. If set to true, the `filter` - * field is interpreteted according to the new, attribute-based syntax. - * @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 {@link google.cloud.retail.v2beta.PredictResponse | 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'placement': request.placement ?? '', - }); - this.initialize(); - return this.innerApiCalls.predict(request, options, callback); - } - -/** - * Gets information about a location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Resource name for the location. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * ``` - * const [response] = await client.getLocation(request); - * ``` - */ - getLocation( - request: LocationProtos.google.cloud.location.IGetLocationRequest, - options?: - | gax.CallOptions - | Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - > - ): Promise { - return this.locationsClient.getLocation(request, options, callback); - } - -/** - * Lists information about the supported locations for this service. Returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The resource that owns the locations collection, if applicable. - * @param {string} request.filter - * The standard list filter. - * @param {number} request.pageSize - * The standard list page size. - * @param {string} request.pageToken - * The standard list page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example - * ``` - * const iterable = client.listLocationsAsync(request); - * for await (const response of iterable) { - * // process response - * } - * ``` - */ - listLocationsAsync( - request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions - ): AsyncIterable { - return this.locationsClient.listLocationsAsync(request, options); - } - -/** - * Gets the latest state of a long-running operation. Clients can use this - * method to poll the operation result at intervals as recommended by the API - * service. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error, ?Object)=} callback - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * const name = ''; - * const [response] = await client.getOperation({name}); - * // doThingsWith(response) - * ``` - */ - getOperation( - request: protos.google.longrunning.GetOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - > - ): Promise<[protos.google.longrunning.Operation]> { - return this.operationsClient.getOperation(request, options, callback); - } - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. - * - * For-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation collection. - * @param {string} request.filter - The standard list filter. - * @param {number=} request.pageSize - - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @returns {Object} - * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * for await (const response of client.listOperationsAsync(request)); - * // doThingsWith(response) - * ``` - */ - listOperationsAsync( - request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions - ): AsyncIterable { - return this.operationsClient.listOperationsAsync(request, options); - } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * {@link Operations.GetOperation} or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an {@link Operation.error} value with a {@link google.rpc.Status.code} of - * 1, corresponding to `Code.CANCELLED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be cancelled. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.cancelOperation({name: ''}); - * ``` - */ - cancelOperation( - request: protos.google.longrunning.CancelOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.CancelOperationRequest, - {} | undefined | null - >, - callback?: Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - > - ): Promise { - return this.operationsClient.cancelOperation(request, options, callback); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be deleted. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.deleteOperation({name: ''}); - * ``` - */ - deleteOperation( - request: protos.google.longrunning.DeleteOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - > - ): Promise { - return this.operationsClient.deleteOperation(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified 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 model resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} model - * @returns {string} Resource name string. - */ - modelPath(project:string,location:string,catalog:string,model:string) { - return this.pathTemplates.modelPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - model: model, - }); - } - - /** - * Parse the project from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the project. - */ - matchProjectFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).project; - } - - /** - * Parse the location from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the location. - */ - matchLocationFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).location; - } - - /** - * Parse the catalog from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).catalog; - } - - /** - * Parse the model from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the model. - */ - matchModelFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).model; - } - - /** - * 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(); - this.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/prediction_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/prediction_service_client_config.json deleted file mode 100644 index ab64c45e11f..00000000000 --- a/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2beta/src/v2beta/prediction_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/prediction_service_proto_list.json deleted file mode 100644 index ce2a33ebd29..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/prediction_service_proto_list.json +++ /dev/null @@ -1,22 +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/model.proto", - "../../protos/google/cloud/retail/v2beta/model_service.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/google-cloud-retail/v2beta/src/v2beta/product_service_client.ts b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/product_service_client.ts deleted file mode 100644 index e500acd18bb..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/product_service_client.ts +++ /dev/null @@ -1,2865 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/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'; -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}; - locationsClient: LocationsClient; - 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/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new ProductServiceClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof 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); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - this.locationsClient = new this._gaxModule.LocationsClient( - this._gaxGrpc, - opts - ); - - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - 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}' - ), - modelPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' - ), - 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. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',additional_bindings: [{get: '/v2beta/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2beta/{name=projects/*/locations/*/operations/*}',},{get: '/v2beta/{name=projects/*/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2beta/{name=projects/*/locations/*/catalogs/*}/operations',additional_bindings: [{get: '/v2beta/{name=projects/*/locations/*}/operations',},{get: '/v2beta/{name=projects/*}/operations',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).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 = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.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._opts.fallback - ); - - 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 {@link google.cloud.retail.v2beta.Product | 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' - ] = this._gaxModule.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 {@link google.cloud.retail.v2beta.Product | 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' - ] = this._gaxModule.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. - * - * 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.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 {@link google.cloud.retail.v2beta.Product | 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' - ] = this._gaxModule.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 {@link google.protobuf.Empty | 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' - ] = this._gaxModule.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. - * 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, all fields are updated. - * @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 - * Full Pub/Sub topic name for receiving notification. If this field is set, - * when the import is finished, a notification is sent to - * specified Pub/Sub topic. The message data is 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.v2beta.ImportProductsRequest.parent|ImportProductsRequest.parent}. - * Make sure that `service-@gcp-sa-retail.iam.gserviceaccount.com` has the - * `pubsub.topics.publish` IAM permission on the 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/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' - ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.importProducts, this._gaxModule.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 is 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|ProductService.GetProduct} - * or - * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts}. - * - * When inventory is updated with - * {@link google.cloud.retail.v2beta.ProductService.CreateProduct|ProductService.CreateProduct} - * and - * {@link google.cloud.retail.v2beta.ProductService.UpdateProduct|ProductService.UpdateProduct}, - * the specified inventory field value(s) overwrite any existing value(s) - * while ignoring the last update time for this field. Furthermore, the last - * update times for the specified inventory fields are overwritten by the - * times of the - * {@link google.cloud.retail.v2beta.ProductService.CreateProduct|ProductService.CreateProduct} - * or - * {@link google.cloud.retail.v2beta.ProductService.UpdateProduct|ProductService.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 is used. - * - * If no inventory fields are set in - * {@link google.cloud.retail.v2beta.SetInventoryRequest.set_mask|SetInventoryRequest.set_mask}, - * then any existing inventory information is preserved. - * - * Pre-existing inventory information can only be updated with - * {@link google.cloud.retail.v2beta.ProductService.SetInventory|ProductService.SetInventory}, - * {@link google.cloud.retail.v2beta.ProductService.AddFulfillmentPlaces|ProductService.AddFulfillmentPlaces}, - * and - * {@link google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces|ProductService.RemoveFulfillmentPlaces}. - * - * The returned {@link google.longrunning.Operation|Operation}s is obsolete after - * one day, and the {@link google.longrunning.Operations.GetOperation|GetOperation} - * API returns `NOT_FOUND` afterwards. - * - * If conflicting updates are issued, the - * {@link google.longrunning.Operation|Operation}s associated with the stale - * updates are not marked as {@link google.longrunning.Operation.done|done} until - * they are obsolete. - * - * @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 google.cloud.retail.v2beta.Product.name|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 google.cloud.retail.v2beta.Product.fulfillment_info|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 google.cloud.retail.v2beta.Product.fulfillment_info|SetInventoryRequest.inventory.fulfillment_info} - * * Checks that only the desired fulfillment info types have empty - * {@link google.cloud.retail.v2beta.FulfillmentInfo.place_ids|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 google.cloud.retail.v2beta.ProductService.UpdateProduct|ProductService.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' - ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.setInventory, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * It is recommended to use the - * {@link google.cloud.retail.v2beta.ProductService.AddLocalInventories|ProductService.AddLocalInventories} - * method instead of - * {@link google.cloud.retail.v2beta.ProductService.AddFulfillmentPlaces|ProductService.AddFulfillmentPlaces}. - * {@link google.cloud.retail.v2beta.ProductService.AddLocalInventories|ProductService.AddLocalInventories} - * achieves the same results but provides more fine-grained control over - * ingesting local inventory data. - * - * 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|ProductService.GetProduct} - * or - * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts}. - * - * The returned {@link google.longrunning.Operation|Operation}s will be obsolete - * after 1 day, and {@link google.longrunning.Operations.GetOperation|GetOperation} - * API will return NOT_FOUND afterwards. - * - * If conflicting updates are issued, the - * {@link google.longrunning.Operation|Operation}s associated with the stale - * updates will not be marked as {@link google.longrunning.Operation.done|done} - * until being obsolete. - * - * @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 google.cloud.retail.v2beta.FulfillmentInfo.type|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' - ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.addFulfillmentPlaces, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * It is recommended to use the - * {@link google.cloud.retail.v2beta.ProductService.RemoveLocalInventories|ProductService.RemoveLocalInventories} - * method instead of - * {@link google.cloud.retail.v2beta.ProductService.RemoveFulfillmentPlaces|ProductService.RemoveFulfillmentPlaces}. - * {@link google.cloud.retail.v2beta.ProductService.RemoveLocalInventories|ProductService.RemoveLocalInventories} - * achieves the same results but provides more fine-grained control over - * ingesting local inventory data. - * - * 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|ProductService.GetProduct} - * or - * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts}. - * - * The returned {@link google.longrunning.Operation|Operation}s will be obsolete - * after 1 day, and {@link google.longrunning.Operations.GetOperation|GetOperation} - * API will return NOT_FOUND afterwards. - * - * If conflicting updates are issued, the - * {@link google.longrunning.Operation|Operation}s associated with the stale - * updates will not be marked as {@link google.longrunning.Operation.done|done} - * until being obsolete. - * - * @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 google.cloud.retail.v2beta.FulfillmentInfo.type|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' - ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.removeFulfillmentPlaces, this._gaxModule.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|ProductService.GetProduct} - * or - * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts}. - * - * Local inventory information can only be modified using this method. - * {@link google.cloud.retail.v2beta.ProductService.CreateProduct|ProductService.CreateProduct} - * and - * {@link google.cloud.retail.v2beta.ProductService.UpdateProduct|ProductService.UpdateProduct} - * has no effect on local inventories. - * - * The returned {@link google.longrunning.Operation|Operation}s will be obsolete - * after 1 day, and {@link google.longrunning.Operations.GetOperation|GetOperation} - * API will return NOT_FOUND afterwards. - * - * If conflicting updates are issued, the - * {@link google.longrunning.Operation|Operation}s associated with the stale - * updates will not be marked as {@link google.longrunning.Operation.done|done} - * until being obsolete. - * - * @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' - ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.addLocalInventories, this._gaxModule.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|ProductService.GetProduct} - * or - * {@link google.cloud.retail.v2beta.ProductService.ListProducts|ProductService.ListProducts}. - * - * Local inventory information can only be removed using this method. - * {@link google.cloud.retail.v2beta.ProductService.CreateProduct|ProductService.CreateProduct} - * and - * {@link google.cloud.retail.v2beta.ProductService.UpdateProduct|ProductService.UpdateProduct} - * has no effect on local inventories. - * - * The returned {@link google.longrunning.Operation|Operation}s will be obsolete - * after 1 day, and {@link google.longrunning.Operations.GetOperation|GetOperation} - * API will return NOT_FOUND afterwards. - * - * If conflicting updates are issued, the - * {@link google.longrunning.Operation|Operation}s associated with the stale - * updates will not be marked as {@link google.longrunning.Operation.done|done} - * until being obsolete. - * - * @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' - ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.removeLocalInventories, this._gaxModule.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 {@link google.cloud.retail.v2beta.Product | 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - this.initialize(); - return this.innerApiCalls.listProducts(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The 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 {@link google.cloud.retail.v2beta.Product | 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listProducts']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProducts.createStream( - this.innerApiCalls.listProducts as GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listProducts`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The 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 - * {@link google.cloud.retail.v2beta.Product | 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' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listProducts']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listProducts.asyncIterate( - this.innerApiCalls['listProducts'] as GaxCall, - request as {}, - callSettings - ) as AsyncIterable; - } -/** - * Gets information about a location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Resource name for the location. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * ``` - * const [response] = await client.getLocation(request); - * ``` - */ - getLocation( - request: LocationProtos.google.cloud.location.IGetLocationRequest, - options?: - | gax.CallOptions - | Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - > - ): Promise { - return this.locationsClient.getLocation(request, options, callback); - } - -/** - * Lists information about the supported locations for this service. Returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The resource that owns the locations collection, if applicable. - * @param {string} request.filter - * The standard list filter. - * @param {number} request.pageSize - * The standard list page size. - * @param {string} request.pageToken - * The standard list page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example - * ``` - * const iterable = client.listLocationsAsync(request); - * for await (const response of iterable) { - * // process response - * } - * ``` - */ - listLocationsAsync( - request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions - ): AsyncIterable { - return this.locationsClient.listLocationsAsync(request, options); - } - -/** - * Gets the latest state of a long-running operation. Clients can use this - * method to poll the operation result at intervals as recommended by the API - * service. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error, ?Object)=} callback - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * const name = ''; - * const [response] = await client.getOperation({name}); - * // doThingsWith(response) - * ``` - */ - getOperation( - request: protos.google.longrunning.GetOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - > - ): Promise<[protos.google.longrunning.Operation]> { - return this.operationsClient.getOperation(request, options, callback); - } - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. - * - * For-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation collection. - * @param {string} request.filter - The standard list filter. - * @param {number=} request.pageSize - - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @returns {Object} - * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * for await (const response of client.listOperationsAsync(request)); - * // doThingsWith(response) - * ``` - */ - listOperationsAsync( - request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions - ): AsyncIterable { - return this.operationsClient.listOperationsAsync(request, options); - } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * {@link Operations.GetOperation} or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an {@link Operation.error} value with a {@link google.rpc.Status.code} of - * 1, corresponding to `Code.CANCELLED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be cancelled. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.cancelOperation({name: ''}); - * ``` - */ - cancelOperation( - request: protos.google.longrunning.CancelOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.CancelOperationRequest, - {} | undefined | null - >, - callback?: Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - > - ): Promise { - return this.operationsClient.cancelOperation(request, options, callback); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be deleted. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.deleteOperation({name: ''}); - * ``` - */ - deleteOperation( - request: protos.google.longrunning.DeleteOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - > - ): Promise { - return this.operationsClient.deleteOperation(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified 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 model resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} model - * @returns {string} Resource name string. - */ - modelPath(project:string,location:string,catalog:string,model:string) { - return this.pathTemplates.modelPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - model: model, - }); - } - - /** - * Parse the project from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the project. - */ - matchProjectFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).project; - } - - /** - * Parse the location from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the location. - */ - matchLocationFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).location; - } - - /** - * Parse the catalog from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).catalog; - } - - /** - * Parse the model from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the model. - */ - matchModelFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).model; - } - - /** - * 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.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/product_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/product_service_client_config.json deleted file mode 100644 index 459b579d7a8..00000000000 --- a/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2beta/src/v2beta/product_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/product_service_proto_list.json deleted file mode 100644 index ce2a33ebd29..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/product_service_proto_list.json +++ /dev/null @@ -1,22 +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/model.proto", - "../../protos/google/cloud/retail/v2beta/model_service.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/google-cloud-retail/v2beta/src/v2beta/search_service_client.ts b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/search_service_client.ts deleted file mode 100644 index 4fbb71261e3..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/search_service_client.ts +++ /dev/null @@ -1,2043 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/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. - * 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}; - locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - 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/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new SearchServiceClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof 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); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - this.locationsClient = new this._gaxModule.LocationsClient( - this._gaxGrpc, - opts - ); - - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - 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}' - ), - experimentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/experiments/{experiment}' - ), - modelPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' - ), - 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') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',additional_bindings: [{get: '/v2beta/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2beta/{name=projects/*/locations/*/operations/*}',},{get: '/v2beta/{name=projects/*/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2beta/{name=projects/*/locations/*/catalogs/*}/operations',additional_bindings: [{get: '/v2beta/{name=projects/*/locations/*}/operations',},{get: '/v2beta/{name=projects/*}/operations',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - - this.descriptors.longrunning = { - }; - - // 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 = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.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._opts.fallback - ); - - 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. - * 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 Retail Search serving config, such as - * `projects/* /locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` - * or the name of the legacy placement resource, such as - * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. - * This field is used to identify the serving config 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.v2beta.SearchRequest.filter|filter} and - * {@link google.cloud.retail.v2beta.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.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 200 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 - * {@link google.cloud.retail.v2beta.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.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 google.cloud.retail.v2beta.LocalInventory.attributes|Product.local_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. Must be set 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, 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. - * - * Notice that if both - * {@link google.cloud.retail.v2beta.ServingConfig.personalization_spec|ServingConfig.personalization_spec} - * and - * {@link google.cloud.retail.v2beta.SearchRequest.personalization_spec|SearchRequest.personalization_spec} - * are set. - * {@link google.cloud.retail.v2beta.SearchRequest.personalization_spec|SearchRequest.personalization_spec} - * will override - * {@link google.cloud.retail.v2beta.ServingConfig.personalization_spec|ServingConfig.personalization_spec}. - * @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.v2beta.SearchRequest.SpellCorrectionSpec} request.spellCorrectionSpec - * The spell correction specification that specifies the mode under - * which spell correction will take effect. - * @param {string} request.entity - * The entity for customers that may run multiple different entities, domains, - * sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, - * `google.com`, `youtube.com`, etc. - * If this is set, it should be exactly matched with - * {@link google.cloud.retail.v2beta.UserEvent.entity|UserEvent.entity} to get - * search results boosted by entity. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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 {@link google.cloud.retail.v2beta.SearchResponse.SearchResult | 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' - ] = this._gaxModule.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 Retail Search serving config, such as - * `projects/* /locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` - * or the name of the legacy placement resource, such as - * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. - * This field is used to identify the serving config 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.v2beta.SearchRequest.filter|filter} and - * {@link google.cloud.retail.v2beta.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.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 200 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 - * {@link google.cloud.retail.v2beta.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.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 google.cloud.retail.v2beta.LocalInventory.attributes|Product.local_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. Must be set 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, 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. - * - * Notice that if both - * {@link google.cloud.retail.v2beta.ServingConfig.personalization_spec|ServingConfig.personalization_spec} - * and - * {@link google.cloud.retail.v2beta.SearchRequest.personalization_spec|SearchRequest.personalization_spec} - * are set. - * {@link google.cloud.retail.v2beta.SearchRequest.personalization_spec|SearchRequest.personalization_spec} - * will override - * {@link google.cloud.retail.v2beta.ServingConfig.personalization_spec|ServingConfig.personalization_spec}. - * @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.v2beta.SearchRequest.SpellCorrectionSpec} request.spellCorrectionSpec - * The spell correction specification that specifies the mode under - * which spell correction will take effect. - * @param {string} request.entity - * The entity for customers that may run multiple different entities, domains, - * sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, - * `google.com`, `youtube.com`, etc. - * If this is set, it should be exactly matched with - * {@link google.cloud.retail.v2beta.UserEvent.entity|UserEvent.entity} to get - * search results boosted by entity. - * @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 {@link google.cloud.retail.v2beta.SearchResponse.SearchResult | 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' - ] = this._gaxModule.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 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 Retail Search serving config, such as - * `projects/* /locations/global/catalogs/default_catalog/servingConfigs/default_serving_config` - * or the name of the legacy placement resource, such as - * `projects/* /locations/global/catalogs/default_catalog/placements/default_search`. - * This field is used to identify the serving config 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.v2beta.SearchRequest.filter|filter} and - * {@link google.cloud.retail.v2beta.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.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 200 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 - * {@link google.cloud.retail.v2beta.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.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 google.cloud.retail.v2beta.LocalInventory.attributes|Product.local_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. Must be set 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, 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. - * - * Notice that if both - * {@link google.cloud.retail.v2beta.ServingConfig.personalization_spec|ServingConfig.personalization_spec} - * and - * {@link google.cloud.retail.v2beta.SearchRequest.personalization_spec|SearchRequest.personalization_spec} - * are set. - * {@link google.cloud.retail.v2beta.SearchRequest.personalization_spec|SearchRequest.personalization_spec} - * will override - * {@link google.cloud.retail.v2beta.ServingConfig.personalization_spec|ServingConfig.personalization_spec}. - * @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.v2beta.SearchRequest.SpellCorrectionSpec} request.spellCorrectionSpec - * The spell correction specification that specifies the mode under - * which spell correction will take effect. - * @param {string} request.entity - * The entity for customers that may run multiple different entities, domains, - * sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, - * `google.com`, `youtube.com`, etc. - * If this is set, it should be exactly matched with - * {@link google.cloud.retail.v2beta.UserEvent.entity|UserEvent.entity} to get - * search results boosted by entity. - * @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 - * {@link google.cloud.retail.v2beta.SearchResponse.SearchResult | 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' - ] = this._gaxModule.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 {}, - callSettings - ) as AsyncIterable; - } -/** - * Gets information about a location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Resource name for the location. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * ``` - * const [response] = await client.getLocation(request); - * ``` - */ - getLocation( - request: LocationProtos.google.cloud.location.IGetLocationRequest, - options?: - | gax.CallOptions - | Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - > - ): Promise { - return this.locationsClient.getLocation(request, options, callback); - } - -/** - * Lists information about the supported locations for this service. Returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The resource that owns the locations collection, if applicable. - * @param {string} request.filter - * The standard list filter. - * @param {number} request.pageSize - * The standard list page size. - * @param {string} request.pageToken - * The standard list page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example - * ``` - * const iterable = client.listLocationsAsync(request); - * for await (const response of iterable) { - * // process response - * } - * ``` - */ - listLocationsAsync( - request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions - ): AsyncIterable { - return this.locationsClient.listLocationsAsync(request, options); - } - -/** - * Gets the latest state of a long-running operation. Clients can use this - * method to poll the operation result at intervals as recommended by the API - * service. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error, ?Object)=} callback - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * const name = ''; - * const [response] = await client.getOperation({name}); - * // doThingsWith(response) - * ``` - */ - getOperation( - request: protos.google.longrunning.GetOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - > - ): Promise<[protos.google.longrunning.Operation]> { - return this.operationsClient.getOperation(request, options, callback); - } - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. - * - * For-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation collection. - * @param {string} request.filter - The standard list filter. - * @param {number=} request.pageSize - - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @returns {Object} - * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * for await (const response of client.listOperationsAsync(request)); - * // doThingsWith(response) - * ``` - */ - listOperationsAsync( - request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions - ): AsyncIterable { - return this.operationsClient.listOperationsAsync(request, options); - } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * {@link Operations.GetOperation} or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an {@link Operation.error} value with a {@link google.rpc.Status.code} of - * 1, corresponding to `Code.CANCELLED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be cancelled. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.cancelOperation({name: ''}); - * ``` - */ - cancelOperation( - request: protos.google.longrunning.CancelOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.CancelOperationRequest, - {} | undefined | null - >, - callback?: Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - > - ): Promise { - return this.operationsClient.cancelOperation(request, options, callback); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be deleted. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.deleteOperation({name: ''}); - * ``` - */ - deleteOperation( - request: protos.google.longrunning.DeleteOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - > - ): Promise { - return this.operationsClient.deleteOperation(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified 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 experiment resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} experiment - * @returns {string} Resource name string. - */ - experimentPath(project:string,location:string,catalog:string,experiment:string) { - return this.pathTemplates.experimentPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - experiment: experiment, - }); - } - - /** - * Parse the project from Experiment resource. - * - * @param {string} experimentName - * A fully-qualified path representing Experiment resource. - * @returns {string} A string representing the project. - */ - matchProjectFromExperimentName(experimentName: string) { - return this.pathTemplates.experimentPathTemplate.match(experimentName).project; - } - - /** - * Parse the location from Experiment resource. - * - * @param {string} experimentName - * A fully-qualified path representing Experiment resource. - * @returns {string} A string representing the location. - */ - matchLocationFromExperimentName(experimentName: string) { - return this.pathTemplates.experimentPathTemplate.match(experimentName).location; - } - - /** - * Parse the catalog from Experiment resource. - * - * @param {string} experimentName - * A fully-qualified path representing Experiment resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromExperimentName(experimentName: string) { - return this.pathTemplates.experimentPathTemplate.match(experimentName).catalog; - } - - /** - * Parse the experiment from Experiment resource. - * - * @param {string} experimentName - * A fully-qualified path representing Experiment resource. - * @returns {string} A string representing the experiment. - */ - matchExperimentFromExperimentName(experimentName: string) { - return this.pathTemplates.experimentPathTemplate.match(experimentName).experiment; - } - - /** - * Return a fully-qualified model resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} model - * @returns {string} Resource name string. - */ - modelPath(project:string,location:string,catalog:string,model:string) { - return this.pathTemplates.modelPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - model: model, - }); - } - - /** - * Parse the project from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the project. - */ - matchProjectFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).project; - } - - /** - * Parse the location from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the location. - */ - matchLocationFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).location; - } - - /** - * Parse the catalog from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).catalog; - } - - /** - * Parse the model from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the model. - */ - matchModelFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).model; - } - - /** - * 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(); - this.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/search_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/search_service_client_config.json deleted file mode 100644 index 82de0f81873..00000000000 --- a/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2beta/src/v2beta/search_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/search_service_proto_list.json deleted file mode 100644 index ce2a33ebd29..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/search_service_proto_list.json +++ /dev/null @@ -1,22 +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/model.proto", - "../../protos/google/cloud/retail/v2beta/model_service.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/google-cloud-retail/v2beta/src/v2beta/serving_config_service_client.ts b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/serving_config_service_client.ts deleted file mode 100644 index 6c869c15f11..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/serving_config_service_client.ts +++ /dev/null @@ -1,1693 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/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}; - locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; - 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/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new ServingConfigServiceClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof 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); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - this.locationsClient = new this._gaxModule.LocationsClient( - this._gaxGrpc, - opts - ); - - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - 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}' - ), - modelPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' - ), - 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') - }; - - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',additional_bindings: [{get: '/v2beta/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2beta/{name=projects/*/locations/*/operations/*}',},{get: '/v2beta/{name=projects/*/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2beta/{name=projects/*/locations/*/catalogs/*}/operations',additional_bindings: [{get: '/v2beta/{name=projects/*/locations/*}/operations',},{get: '/v2beta/{name=projects/*}/operations',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); - - this.descriptors.longrunning = { - }; - - // 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 = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.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._opts.fallback - ); - - 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 {@link google.cloud.retail.v2beta.ServingConfig | 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' - ] = this._gaxModule.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 {@link google.protobuf.Empty | 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' - ] = this._gaxModule.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 {@link google.cloud.retail.v2beta.ServingConfig | 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' - ] = this._gaxModule.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 {@link google.cloud.retail.v2beta.ServingConfig | 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' - ] = this._gaxModule.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 {@link google.cloud.retail.v2beta.ServingConfig | 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' - ] = this._gaxModule.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 {@link google.cloud.retail.v2beta.ServingConfig | 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' - ] = this._gaxModule.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 {@link google.cloud.retail.v2beta.ServingConfig | 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' - ] = this._gaxModule.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 {@link google.cloud.retail.v2beta.ServingConfig | 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' - ] = this._gaxModule.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 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 - * {@link google.cloud.retail.v2beta.ServingConfig | 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' - ] = this._gaxModule.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 {}, - callSettings - ) as AsyncIterable; - } -/** - * Gets information about a location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Resource name for the location. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * ``` - * const [response] = await client.getLocation(request); - * ``` - */ - getLocation( - request: LocationProtos.google.cloud.location.IGetLocationRequest, - options?: - | gax.CallOptions - | Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - > - ): Promise { - return this.locationsClient.getLocation(request, options, callback); - } - -/** - * Lists information about the supported locations for this service. Returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The resource that owns the locations collection, if applicable. - * @param {string} request.filter - * The standard list filter. - * @param {number} request.pageSize - * The standard list page size. - * @param {string} request.pageToken - * The standard list page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example - * ``` - * const iterable = client.listLocationsAsync(request); - * for await (const response of iterable) { - * // process response - * } - * ``` - */ - listLocationsAsync( - request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions - ): AsyncIterable { - return this.locationsClient.listLocationsAsync(request, options); - } - -/** - * Gets the latest state of a long-running operation. Clients can use this - * method to poll the operation result at intervals as recommended by the API - * service. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error, ?Object)=} callback - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * const name = ''; - * const [response] = await client.getOperation({name}); - * // doThingsWith(response) - * ``` - */ - getOperation( - request: protos.google.longrunning.GetOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - > - ): Promise<[protos.google.longrunning.Operation]> { - return this.operationsClient.getOperation(request, options, callback); - } - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. - * - * For-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation collection. - * @param {string} request.filter - The standard list filter. - * @param {number=} request.pageSize - - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @returns {Object} - * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * for await (const response of client.listOperationsAsync(request)); - * // doThingsWith(response) - * ``` - */ - listOperationsAsync( - request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions - ): AsyncIterable { - return this.operationsClient.listOperationsAsync(request, options); - } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * {@link Operations.GetOperation} or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an {@link Operation.error} value with a {@link google.rpc.Status.code} of - * 1, corresponding to `Code.CANCELLED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be cancelled. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.cancelOperation({name: ''}); - * ``` - */ - cancelOperation( - request: protos.google.longrunning.CancelOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.CancelOperationRequest, - {} | undefined | null - >, - callback?: Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - > - ): Promise { - return this.operationsClient.cancelOperation(request, options, callback); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be deleted. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.deleteOperation({name: ''}); - * ``` - */ - deleteOperation( - request: protos.google.longrunning.DeleteOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - > - ): Promise { - return this.operationsClient.deleteOperation(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified 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 model resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} model - * @returns {string} Resource name string. - */ - modelPath(project:string,location:string,catalog:string,model:string) { - return this.pathTemplates.modelPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - model: model, - }); - } - - /** - * Parse the project from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the project. - */ - matchProjectFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).project; - } - - /** - * Parse the location from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the location. - */ - matchLocationFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).location; - } - - /** - * Parse the catalog from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).catalog; - } - - /** - * Parse the model from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the model. - */ - matchModelFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).model; - } - - /** - * 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(); - this.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/serving_config_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/serving_config_service_client_config.json deleted file mode 100644 index 2d17b5273c2..00000000000 --- a/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2beta/src/v2beta/serving_config_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/serving_config_service_proto_list.json deleted file mode 100644 index ce2a33ebd29..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/serving_config_service_proto_list.json +++ /dev/null @@ -1,22 +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/model.proto", - "../../protos/google/cloud/retail/v2beta/model_service.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/google-cloud-retail/v2beta/src/v2beta/user_event_service_client.ts b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/user_event_service_client.ts deleted file mode 100644 index 9cf218fd868..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/user_event_service_client.ts +++ /dev/null @@ -1,1560 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, LocationsClient, LocationProtos} 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'; -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}; - locationsClient: LocationsClient; - 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/main/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode. - * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. - * For more information, please check the - * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. - * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you - * need to avoid loading the default gRPC version and want to use the fallback - * HTTP implementation. Load only fallback version and pass it to the constructor: - * ``` - * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC - * const client = new UserEventServiceClient({fallback: 'rest'}, gax); - * ``` - */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof 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); - - // Request numeric enum values if REST transport is used. - opts.numericEnums = true; - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Load google-gax module synchronously if needed - if (!gaxInstance) { - gaxInstance = require('google-gax') as typeof gax; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - this.locationsClient = new this._gaxModule.LocationsClient( - this._gaxGrpc, - opts - ); - - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - 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}' - ), - modelPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/catalogs/{catalog}/models/{model}' - ), - 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. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.longrunning.Operations.GetOperation',get: '/v2beta/{name=projects/*/locations/*/catalogs/*/branches/*/operations/*}',additional_bindings: [{get: '/v2beta/{name=projects/*/locations/*/catalogs/*/operations/*}',},{get: '/v2beta/{name=projects/*/locations/*/operations/*}',},{get: '/v2beta/{name=projects/*/operations/*}',}], - },{selector: 'google.longrunning.Operations.ListOperations',get: '/v2beta/{name=projects/*/locations/*/catalogs/*}/operations',additional_bindings: [{get: '/v2beta/{name=projects/*/locations/*}/operations',},{get: '/v2beta/{name=projects/*}/operations',}], - }]; - } - this.operationsClient = this._gaxModule.lro(lroOptions).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 = this._gaxModule.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.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._opts.fallback - ); - - 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 {boolean} request.writeAsync - * If set to true, the user event will be written asynchronously after - * validation, and the API will respond without waiting for the write. - * Therefore, silent failures can occur even if the API returns success. In - * case of silent failures, error messages can be found in Stackdriver logs. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.retail.v2beta.UserEvent | 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' - ] = this._gaxModule.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.prebuiltRule - * The prebuilt rule name that can convert a specific type of raw_json. - * For example: "ga4_bq" rule for the GA4 user event schema. - * @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 {string} request.rawJson - * An arbitrary serialized JSON string that contains necessary information - * that can comprise a user event. When this field is specified, the - * user_event field will be ignored. Note: line-delimited JSON is not - * supported, a single JSON only. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.api.HttpBody | 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' - ] = this._gaxModule.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' - ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.purgeUserEvents, this._gaxModule.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' - ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.importUserEvents, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Starts a user-event rejoin operation with latest product catalog. Events - * are not annotated with detailed product information for products that are - * missing from the catalog when the user event is ingested. These - * events are stored as unjoined events with limited usage on training and - * serving. You can use this method to start a join operation on specified - * events with the latest version of product catalog. You can also use this - * method 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' - ] = this._gaxModule.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 this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); - const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.rejoinUserEvents, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } -/** - * Gets information about a location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Resource name for the location. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html | CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.cloud.location.Location | Location}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example - * ``` - * const [response] = await client.getLocation(request); - * ``` - */ - getLocation( - request: LocationProtos.google.cloud.location.IGetLocationRequest, - options?: - | gax.CallOptions - | Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - LocationProtos.google.cloud.location.ILocation, - | LocationProtos.google.cloud.location.IGetLocationRequest - | null - | undefined, - {} | null | undefined - > - ): Promise { - return this.locationsClient.getLocation(request, options, callback); - } - -/** - * Lists information about the supported locations for this service. Returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The resource that owns the locations collection, if applicable. - * @param {string} request.filter - * The standard list filter. - * @param {number} request.pageSize - * The standard list page size. - * @param {string} request.pageToken - * The standard list page token. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * {@link google.cloud.location.Location | Location}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example - * ``` - * const iterable = client.listLocationsAsync(request); - * for await (const response of iterable) { - * // process response - * } - * ``` - */ - listLocationsAsync( - request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions - ): AsyncIterable { - return this.locationsClient.listLocationsAsync(request, options); - } - -/** - * Gets the latest state of a long-running operation. Clients can use this - * method to poll the operation result at intervals as recommended by the API - * service. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error, ?Object)=} callback - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * {@link google.longrunning.Operation | google.longrunning.Operation}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * const name = ''; - * const [response] = await client.getOperation({name}); - * // doThingsWith(response) - * ``` - */ - getOperation( - request: protos.google.longrunning.GetOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.longrunning.Operation, - protos.google.longrunning.GetOperationRequest, - {} | null | undefined - > - ): Promise<[protos.google.longrunning.Operation]> { - return this.operationsClient.getOperation(request, options, callback); - } - /** - * Lists operations that match the specified filter in the request. If the - * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. - * - * For-await-of syntax is used with the iterable to recursively get response element on-demand. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation collection. - * @param {string} request.filter - The standard list filter. - * @param {number=} request.pageSize - - * The maximum number of resources contained in the underlying API - * response. If page streaming is performed per-resource, this - * parameter does not affect the return value. If page streaming is - * performed per-page, this determines the maximum number of - * resources in a page. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @returns {Object} - * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * for await (const response of client.listOperationsAsync(request)); - * // doThingsWith(response) - * ``` - */ - listOperationsAsync( - request: protos.google.longrunning.ListOperationsRequest, - options?: gax.CallOptions - ): AsyncIterable { - return this.operationsClient.listOperationsAsync(request, options); - } - /** - * Starts asynchronous cancellation on a long-running operation. The server - * makes a best effort to cancel the operation, but success is not - * guaranteed. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. Clients can use - * {@link Operations.GetOperation} or - * other methods to check whether the cancellation succeeded or whether the - * operation completed despite cancellation. On successful cancellation, - * the operation is not deleted; instead, it becomes an operation with - * an {@link Operation.error} value with a {@link google.rpc.Status.code} of - * 1, corresponding to `Code.CANCELLED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be cancelled. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the - * details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.cancelOperation({name: ''}); - * ``` - */ - cancelOperation( - request: protos.google.longrunning.CancelOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.CancelOperationRequest, - {} | undefined | null - >, - callback?: Callback< - protos.google.longrunning.CancelOperationRequest, - protos.google.protobuf.Empty, - {} | undefined | null - > - ): Promise { - return this.operationsClient.cancelOperation(request, options, callback); - } - - /** - * Deletes a long-running operation. This method indicates that the client is - * no longer interested in the operation result. It does not cancel the - * operation. If the server doesn't support this method, it returns - * `google.rpc.Code.UNIMPLEMENTED`. - * - * @param {Object} request - The request object that will be sent. - * @param {string} request.name - The name of the operation resource to be deleted. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, - * e.g, timeout, retries, paginations, etc. See {@link - * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} - * for the details. - * @param {function(?Error)=} callback - * The function which will be called with the result of the API call. - * @return {Promise} - The promise which resolves when API call finishes. - * The promise has a method named "cancel" which cancels the ongoing API - * call. - * - * @example - * ``` - * const client = longrunning.operationsClient(); - * await client.deleteOperation({name: ''}); - * ``` - */ - deleteOperation( - request: protos.google.longrunning.DeleteOperationRequest, - options?: - | gax.CallOptions - | Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.Empty, - protos.google.longrunning.DeleteOperationRequest, - {} | null | undefined - > - ): Promise { - return this.operationsClient.deleteOperation(request, options, callback); - } - - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified 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 model resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} catalog - * @param {string} model - * @returns {string} Resource name string. - */ - modelPath(project:string,location:string,catalog:string,model:string) { - return this.pathTemplates.modelPathTemplate.render({ - project: project, - location: location, - catalog: catalog, - model: model, - }); - } - - /** - * Parse the project from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the project. - */ - matchProjectFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).project; - } - - /** - * Parse the location from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the location. - */ - matchLocationFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).location; - } - - /** - * Parse the catalog from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the catalog. - */ - matchCatalogFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).catalog; - } - - /** - * Parse the model from Model resource. - * - * @param {string} modelName - * A fully-qualified path representing Model resource. - * @returns {string} A string representing the model. - */ - matchModelFromModelName(modelName: string) { - return this.pathTemplates.modelPathTemplate.match(modelName).model; - } - - /** - * 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.locationsClient.close(); - this.operationsClient.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/user_event_service_client_config.json b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/user_event_service_client_config.json deleted file mode 100644 index f5bd2baedcc..00000000000 --- a/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2beta/src/v2beta/user_event_service_proto_list.json b/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/user_event_service_proto_list.json deleted file mode 100644 index ce2a33ebd29..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/src/v2beta/user_event_service_proto_list.json +++ /dev/null @@ -1,22 +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/model.proto", - "../../protos/google/cloud/retail/v2beta/model_service.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/google-cloud-retail/v2beta/system-test/fixtures/sample/src/index.js b/owl-bot-staging/google-cloud-retail/v2beta/system-test/fixtures/sample/src/index.js deleted file mode 100644 index b0a6d36778b..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** 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 modelServiceClient = new retail.ModelServiceClient(); - 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/google-cloud-retail/v2beta/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/google-cloud-retail/v2beta/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 7ee871ea668..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This 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, ModelServiceClient, 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 doStuffWithModelServiceClient(client: ModelServiceClient) { - 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 modelServiceClient = new ModelServiceClient(); - doStuffWithModelServiceClient(modelServiceClient); - // 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/google-cloud-retail/v2beta/system-test/install.ts b/owl-bot-staging/google-cloud-retail/v2beta/system-test/install.ts deleted file mode 100644 index c8f81b25a86..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/system-test/install.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import {packNTest} from 'pack-n-play'; -import {readFileSync} from 'fs'; -import {describe, it} from 'mocha'; - -describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } - }; - await packNTest(options); - }); - - it('JavaScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'JavaScript user can use the library', - ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } - }; - await packNTest(options); - }); - -}); diff --git a/owl-bot-staging/google-cloud-retail/v2beta/test/gapic_catalog_service_v2beta.ts b/owl-bot-staging/google-cloud-retail/v2beta/test/gapic_catalog_service_v2beta.ts deleted file mode 100644 index 43d47177d76..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/test/gapic_catalog_service_v2beta.ts +++ /dev/null @@ -1,2520 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This 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, operationsProtos, LocationProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function 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', () => { - describe('Common methods', () => { - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateCatalogRequest', ['catalog', 'name']); - request.catalog.name = defaultValue1; - const expectedHeaderRequestParams = `catalog.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.updateCatalog as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCatalog as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateCatalogRequest', ['catalog', 'name']); - request.catalog.name = defaultValue1; - const expectedHeaderRequestParams = `catalog.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.updateCatalog as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCatalog as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateCatalogRequest', ['catalog', 'name']); - request.catalog.name = defaultValue1; - const expectedHeaderRequestParams = `catalog.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateCatalog = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateCatalog(request), expectedError); - const actualRequest = (client.innerApiCalls.updateCatalog as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCatalog as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateCatalogRequest', ['catalog', 'name']); - request.catalog.name = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.SetDefaultBranchRequest', ['catalog']); - request.catalog = defaultValue1; - const expectedHeaderRequestParams = `catalog=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.setDefaultBranch = stubSimpleCall(expectedResponse); - const [response] = await client.setDefaultBranch(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setDefaultBranch as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setDefaultBranch as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.SetDefaultBranchRequest', ['catalog']); - request.catalog = defaultValue1; - const expectedHeaderRequestParams = `catalog=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.setDefaultBranch as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setDefaultBranch as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.SetDefaultBranchRequest', ['catalog']); - request.catalog = defaultValue1; - const expectedHeaderRequestParams = `catalog=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.setDefaultBranch = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setDefaultBranch(request), expectedError); - const actualRequest = (client.innerApiCalls.setDefaultBranch as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setDefaultBranch as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.SetDefaultBranchRequest', ['catalog']); - request.catalog = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.GetDefaultBranchRequest', ['catalog']); - request.catalog = defaultValue1; - const expectedHeaderRequestParams = `catalog=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getDefaultBranch as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDefaultBranch as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.GetDefaultBranchRequest', ['catalog']); - request.catalog = defaultValue1; - const expectedHeaderRequestParams = `catalog=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getDefaultBranch as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDefaultBranch as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.GetDefaultBranchRequest', ['catalog']); - request.catalog = defaultValue1; - const expectedHeaderRequestParams = `catalog=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getDefaultBranch = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getDefaultBranch(request), expectedError); - const actualRequest = (client.innerApiCalls.getDefaultBranch as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDefaultBranch as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.GetDefaultBranchRequest', ['catalog']); - request.catalog = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.GetCompletionConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getCompletionConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCompletionConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.GetCompletionConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getCompletionConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCompletionConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.GetCompletionConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getCompletionConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getCompletionConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.getCompletionConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCompletionConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.GetCompletionConfigRequest', ['name']); - request.name = defaultValue1; - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateCompletionConfigRequest', ['completionConfig', 'name']); - request.completionConfig.name = defaultValue1; - const expectedHeaderRequestParams = `completion_config.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.updateCompletionConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCompletionConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateCompletionConfigRequest', ['completionConfig', 'name']); - request.completionConfig.name = defaultValue1; - const expectedHeaderRequestParams = `completion_config.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.updateCompletionConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCompletionConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateCompletionConfigRequest', ['completionConfig', 'name']); - request.completionConfig.name = defaultValue1; - const expectedHeaderRequestParams = `completion_config.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateCompletionConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateCompletionConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.updateCompletionConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCompletionConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateCompletionConfigRequest', ['completionConfig', 'name']); - request.completionConfig.name = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.GetAttributesConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getAttributesConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAttributesConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.GetAttributesConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getAttributesConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAttributesConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.GetAttributesConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getAttributesConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getAttributesConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.getAttributesConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAttributesConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.GetAttributesConfigRequest', ['name']); - request.name = defaultValue1; - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateAttributesConfigRequest', ['attributesConfig', 'name']); - request.attributesConfig.name = defaultValue1; - const expectedHeaderRequestParams = `attributes_config.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.updateAttributesConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateAttributesConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateAttributesConfigRequest', ['attributesConfig', 'name']); - request.attributesConfig.name = defaultValue1; - const expectedHeaderRequestParams = `attributes_config.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.updateAttributesConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateAttributesConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateAttributesConfigRequest', ['attributesConfig', 'name']); - request.attributesConfig.name = defaultValue1; - const expectedHeaderRequestParams = `attributes_config.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateAttributesConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateAttributesConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.updateAttributesConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateAttributesConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateAttributesConfigRequest', ['attributesConfig', 'name']); - request.attributesConfig.name = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.AddCatalogAttributeRequest', ['attributesConfig']); - request.attributesConfig = defaultValue1; - const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.addCatalogAttribute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addCatalogAttribute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.AddCatalogAttributeRequest', ['attributesConfig']); - request.attributesConfig = defaultValue1; - const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.addCatalogAttribute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addCatalogAttribute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.AddCatalogAttributeRequest', ['attributesConfig']); - request.attributesConfig = defaultValue1; - const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.addCatalogAttribute = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.addCatalogAttribute(request), expectedError); - const actualRequest = (client.innerApiCalls.addCatalogAttribute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addCatalogAttribute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.AddCatalogAttributeRequest', ['attributesConfig']); - request.attributesConfig = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.RemoveCatalogAttributeRequest', ['attributesConfig']); - request.attributesConfig = defaultValue1; - const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.removeCatalogAttribute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeCatalogAttribute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.RemoveCatalogAttributeRequest', ['attributesConfig']); - request.attributesConfig = defaultValue1; - const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.removeCatalogAttribute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeCatalogAttribute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.RemoveCatalogAttributeRequest', ['attributesConfig']); - request.attributesConfig = defaultValue1; - const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.removeCatalogAttribute = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.removeCatalogAttribute(request), expectedError); - const actualRequest = (client.innerApiCalls.removeCatalogAttribute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeCatalogAttribute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.RemoveCatalogAttributeRequest', ['attributesConfig']); - request.attributesConfig = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.removeCatalogAttribute(request), expectedError); - }); - }); - - describe('batchRemoveCatalogAttributes', () => { - it('invokes batchRemoveCatalogAttributes 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.BatchRemoveCatalogAttributesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest', ['attributesConfig']); - request.attributesConfig = defaultValue1; - const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse() - ); - client.innerApiCalls.batchRemoveCatalogAttributes = stubSimpleCall(expectedResponse); - const [response] = await client.batchRemoveCatalogAttributes(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.batchRemoveCatalogAttributes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchRemoveCatalogAttributes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes batchRemoveCatalogAttributes 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.BatchRemoveCatalogAttributesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest', ['attributesConfig']); - request.attributesConfig = defaultValue1; - const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2beta.BatchRemoveCatalogAttributesResponse() - ); - client.innerApiCalls.batchRemoveCatalogAttributes = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchRemoveCatalogAttributes( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IBatchRemoveCatalogAttributesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.batchRemoveCatalogAttributes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchRemoveCatalogAttributes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes batchRemoveCatalogAttributes 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.BatchRemoveCatalogAttributesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest', ['attributesConfig']); - request.attributesConfig = defaultValue1; - const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.batchRemoveCatalogAttributes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.batchRemoveCatalogAttributes(request), expectedError); - const actualRequest = (client.innerApiCalls.batchRemoveCatalogAttributes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchRemoveCatalogAttributes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes batchRemoveCatalogAttributes 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.BatchRemoveCatalogAttributesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.BatchRemoveCatalogAttributesRequest', ['attributesConfig']); - request.attributesConfig = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.batchRemoveCatalogAttributes(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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest', ['attributesConfig']); - request.attributesConfig = defaultValue1; - const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.replaceCatalogAttribute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.replaceCatalogAttribute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest', ['attributesConfig']); - request.attributesConfig = defaultValue1; - const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.replaceCatalogAttribute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.replaceCatalogAttribute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest', ['attributesConfig']); - request.attributesConfig = defaultValue1; - const expectedHeaderRequestParams = `attributes_config=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.replaceCatalogAttribute = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.replaceCatalogAttribute(request), expectedError); - const actualRequest = (client.innerApiCalls.replaceCatalogAttribute as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.replaceCatalogAttribute as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ReplaceCatalogAttributeRequest', ['attributesConfig']); - request.attributesConfig = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ListCatalogsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.listCatalogs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCatalogs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ListCatalogsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.listCatalogs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCatalogs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ListCatalogsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listCatalogs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listCatalogs(request), expectedError); - const actualRequest = (client.innerApiCalls.listCatalogs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCatalogs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ListCatalogsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listCatalogs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ListCatalogsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listCatalogs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ListCatalogsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ListCatalogsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listCatalogs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('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('model', () => { - const fakePath = "/rendered/path/model"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - model: "modelValue", - }; - const client = new catalogserviceModule.v2beta.CatalogServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.modelPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.modelPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('modelPath', () => { - const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.modelPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromModelName', () => { - const result = client.matchProjectFromModelName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromModelName', () => { - const result = client.matchLocationFromModelName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromModelName', () => { - const result = client.matchCatalogFromModelName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchModelFromModelName', () => { - const result = client.matchModelFromModelName(fakePath); - assert.strictEqual(result, "modelValue"); - assert((client.pathTemplates.modelPathTemplate.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/google-cloud-retail/v2beta/test/gapic_completion_service_v2beta.ts b/owl-bot-staging/google-cloud-retail/v2beta/test/gapic_completion_service_v2beta.ts deleted file mode 100644 index 866250ab898..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/test/gapic_completion_service_v2beta.ts +++ /dev/null @@ -1,1234 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This 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, LocationProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function 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.CompletionServiceClient', () => { - describe('Common methods', () => { - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.CompleteQueryRequest', ['catalog']); - request.catalog = defaultValue1; - const expectedHeaderRequestParams = `catalog=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.CompleteQueryRequest', ['catalog']); - request.catalog = defaultValue1; - const expectedHeaderRequestParams = `catalog=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.CompleteQueryRequest', ['catalog']); - request.catalog = defaultValue1; - const expectedHeaderRequestParams = `catalog=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.completeQuery = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.completeQuery(request), expectedError); - const actualRequest = (client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.CompleteQueryRequest', ['catalog']); - request.catalog = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ImportCompletionDataRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.importCompletionData as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importCompletionData as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ImportCompletionDataRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.importCompletionData as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importCompletionData as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ImportCompletionDataRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importCompletionData = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importCompletionData(request), expectedError); - const actualRequest = (client.innerApiCalls.importCompletionData as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importCompletionData as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ImportCompletionDataRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importCompletionData = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importCompletionData(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.importCompletionData as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importCompletionData as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('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('model', () => { - const fakePath = "/rendered/path/model"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - model: "modelValue", - }; - const client = new completionserviceModule.v2beta.CompletionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.modelPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.modelPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('modelPath', () => { - const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.modelPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromModelName', () => { - const result = client.matchProjectFromModelName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromModelName', () => { - const result = client.matchLocationFromModelName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromModelName', () => { - const result = client.matchCatalogFromModelName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchModelFromModelName', () => { - const result = client.matchModelFromModelName(fakePath); - assert.strictEqual(result, "modelValue"); - assert((client.pathTemplates.modelPathTemplate.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/google-cloud-retail/v2beta/test/gapic_control_service_v2beta.ts b/owl-bot-staging/google-cloud-retail/v2beta/test/gapic_control_service_v2beta.ts deleted file mode 100644 index 9628b75d93c..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/test/gapic_control_service_v2beta.ts +++ /dev/null @@ -1,1664 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This 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, operationsProtos, LocationProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function 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', () => { - describe('Common methods', () => { - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.CreateControlRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.createControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.CreateControlRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.createControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.CreateControlRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createControl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createControl(request), expectedError); - const actualRequest = (client.innerApiCalls.createControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.CreateControlRequest', ['parent']); - request.parent = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.DeleteControlRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteControl = stubSimpleCall(expectedResponse); - const [response] = await client.deleteControl(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.DeleteControlRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.deleteControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.DeleteControlRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteControl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteControl(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.DeleteControlRequest', ['name']); - request.name = defaultValue1; - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateControlRequest', ['control', 'name']); - request.control.name = defaultValue1; - const expectedHeaderRequestParams = `control.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.updateControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateControlRequest', ['control', 'name']); - request.control.name = defaultValue1; - const expectedHeaderRequestParams = `control.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.updateControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateControlRequest', ['control', 'name']); - request.control.name = defaultValue1; - const expectedHeaderRequestParams = `control.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateControl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateControl(request), expectedError); - const actualRequest = (client.innerApiCalls.updateControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateControlRequest', ['control', 'name']); - request.control.name = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.GetControlRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.GetControlRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.GetControlRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getControl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getControl(request), expectedError); - const actualRequest = (client.innerApiCalls.getControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.GetControlRequest', ['name']); - request.name = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ListControlsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.listControls as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listControls as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ListControlsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.listControls as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listControls as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ListControlsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listControls = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listControls(request), expectedError); - const actualRequest = (client.innerApiCalls.listControls as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listControls as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ListControlsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listControls.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ListControlsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listControls.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ListControlsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listControls.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ListControlsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listControls.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('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('model', () => { - const fakePath = "/rendered/path/model"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - model: "modelValue", - }; - const client = new controlserviceModule.v2beta.ControlServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.modelPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.modelPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('modelPath', () => { - const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.modelPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromModelName', () => { - const result = client.matchProjectFromModelName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromModelName', () => { - const result = client.matchLocationFromModelName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromModelName', () => { - const result = client.matchCatalogFromModelName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchModelFromModelName', () => { - const result = client.matchModelFromModelName(fakePath); - assert.strictEqual(result, "modelValue"); - assert((client.pathTemplates.modelPathTemplate.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/google-cloud-retail/v2beta/test/gapic_model_service_v2beta.ts b/owl-bot-staging/google-cloud-retail/v2beta/test/gapic_model_service_v2beta.ts deleted file mode 100644 index ba13b0eaa9a..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/test/gapic_model_service_v2beta.ts +++ /dev/null @@ -1,2096 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This 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 modelserviceModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf, LROperation, operationsProtos, LocationProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v2beta.ModelServiceClient', () => { - describe('Common methods', () => { - it('has servicePath', () => { - const servicePath = modelserviceModule.v2beta.ModelServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = modelserviceModule.v2beta.ModelServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = modelserviceModule.v2beta.ModelServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new modelserviceModule.v2beta.ModelServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.modelServiceStub, undefined); - await client.initialize(); - assert(client.modelServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.modelServiceStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.modelServiceStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new modelserviceModule.v2beta.ModelServiceClient({ - 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 modelserviceModule.v2beta.ModelServiceClient({ - 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('getModel', () => { - it('invokes getModel without error', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.GetModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.GetModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2beta.Model() - ); - client.innerApiCalls.getModel = stubSimpleCall(expectedResponse); - const [response] = await client.getModel(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getModel without error using callback', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.GetModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.GetModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2beta.Model() - ); - client.innerApiCalls.getModel = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getModel( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IModel|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getModel with error', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.GetModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.GetModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getModel = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getModel(request), expectedError); - const actualRequest = (client.innerApiCalls.getModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getModel with closed client', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.GetModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.GetModelRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getModel(request), expectedError); - }); - }); - - describe('pauseModel', () => { - it('invokes pauseModel without error', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.PauseModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.PauseModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2beta.Model() - ); - client.innerApiCalls.pauseModel = stubSimpleCall(expectedResponse); - const [response] = await client.pauseModel(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.pauseModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pauseModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes pauseModel without error using callback', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.PauseModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.PauseModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2beta.Model() - ); - client.innerApiCalls.pauseModel = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.pauseModel( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IModel|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.pauseModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pauseModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes pauseModel with error', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.PauseModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.PauseModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.pauseModel = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.pauseModel(request), expectedError); - const actualRequest = (client.innerApiCalls.pauseModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pauseModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes pauseModel with closed client', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.PauseModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.PauseModelRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.pauseModel(request), expectedError); - }); - }); - - describe('resumeModel', () => { - it('invokes resumeModel without error', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.ResumeModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ResumeModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2beta.Model() - ); - client.innerApiCalls.resumeModel = stubSimpleCall(expectedResponse); - const [response] = await client.resumeModel(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resumeModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resumeModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resumeModel without error using callback', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.ResumeModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ResumeModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2beta.Model() - ); - client.innerApiCalls.resumeModel = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.resumeModel( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IModel|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resumeModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resumeModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resumeModel with error', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.ResumeModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ResumeModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.resumeModel = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.resumeModel(request), expectedError); - const actualRequest = (client.innerApiCalls.resumeModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resumeModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resumeModel with closed client', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.ResumeModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ResumeModelRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.resumeModel(request), expectedError); - }); - }); - - describe('deleteModel', () => { - it('invokes deleteModel without error', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.DeleteModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.DeleteModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteModel = stubSimpleCall(expectedResponse); - const [response] = await client.deleteModel(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteModel without error using callback', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.DeleteModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.DeleteModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteModel = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteModel( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteModel with error', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.DeleteModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.DeleteModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteModel = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteModel(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteModel with closed client', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.DeleteModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.DeleteModelRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteModel(request), expectedError); - }); - }); - - describe('updateModel', () => { - it('invokes updateModel without error', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.UpdateModelRequest() - ); - request.model ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateModelRequest', ['model', 'name']); - request.model.name = defaultValue1; - const expectedHeaderRequestParams = `model.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2beta.Model() - ); - client.innerApiCalls.updateModel = stubSimpleCall(expectedResponse); - const [response] = await client.updateModel(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateModel without error using callback', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.UpdateModelRequest() - ); - request.model ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateModelRequest', ['model', 'name']); - request.model.name = defaultValue1; - const expectedHeaderRequestParams = `model.name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.retail.v2beta.Model() - ); - client.innerApiCalls.updateModel = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateModel( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IModel|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateModel with error', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.UpdateModelRequest() - ); - request.model ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateModelRequest', ['model', 'name']); - request.model.name = defaultValue1; - const expectedHeaderRequestParams = `model.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateModel = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateModel(request), expectedError); - const actualRequest = (client.innerApiCalls.updateModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateModel with closed client', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.UpdateModelRequest() - ); - request.model ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateModelRequest', ['model', 'name']); - request.model.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateModel(request), expectedError); - }); - }); - - describe('createModel', () => { - it('invokes createModel without error', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.CreateModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.CreateModelRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createModel = stubLongRunningCall(expectedResponse); - const [operation] = await client.createModel(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createModel without error using callback', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.CreateModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.CreateModelRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createModel = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createModel( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createModel with call error', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.CreateModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.CreateModelRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createModel = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createModel(request), expectedError); - const actualRequest = (client.innerApiCalls.createModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createModel with LRO error', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.CreateModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.CreateModelRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createModel = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createModel(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateModelProgress without error', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateModelProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateModelProgress with error', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateModelProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('tuneModel', () => { - it('invokes tuneModel without error', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.TuneModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.TuneModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.tuneModel = stubLongRunningCall(expectedResponse); - const [operation] = await client.tuneModel(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.tuneModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.tuneModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes tuneModel without error using callback', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.TuneModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.TuneModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.tuneModel = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.tuneModel( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.tuneModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.tuneModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes tuneModel with call error', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.TuneModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.TuneModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.tuneModel = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.tuneModel(request), expectedError); - const actualRequest = (client.innerApiCalls.tuneModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.tuneModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes tuneModel with LRO error', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.TuneModelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.TuneModelRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.tuneModel = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.tuneModel(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.tuneModel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.tuneModel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkTuneModelProgress without error', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkTuneModelProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkTuneModelProgress with error', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkTuneModelProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listModels', () => { - it('invokes listModels without error', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.ListModelsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ListModelsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2beta.Model()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Model()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Model()), - ]; - client.innerApiCalls.listModels = stubSimpleCall(expectedResponse); - const [response] = await client.listModels(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listModels as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listModels as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listModels without error using callback', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.ListModelsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ListModelsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2beta.Model()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Model()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Model()), - ]; - client.innerApiCalls.listModels = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listModels( - request, - (err?: Error|null, result?: protos.google.cloud.retail.v2beta.IModel[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listModels as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listModels as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listModels with error', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.ListModelsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ListModelsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listModels = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listModels(request), expectedError); - const actualRequest = (client.innerApiCalls.listModels as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listModels as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listModelsStream without error', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.ListModelsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ListModelsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2beta.Model()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Model()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Model()), - ]; - client.descriptors.page.listModels.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listModelsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2beta.Model[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2beta.Model) => { - 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.listModels.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listModels, request)); - assert( - (client.descriptors.page.listModels.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listModelsStream with error', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.ListModelsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ListModelsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listModels.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listModelsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.retail.v2beta.Model[] = []; - stream.on('data', (response: protos.google.cloud.retail.v2beta.Model) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listModels.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listModels, request)); - assert( - (client.descriptors.page.listModels.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listModels without error', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.ListModelsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ListModelsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.retail.v2beta.Model()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Model()), - generateSampleMessage(new protos.google.cloud.retail.v2beta.Model()), - ]; - client.descriptors.page.listModels.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.retail.v2beta.IModel[] = []; - const iterable = client.listModelsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listModels.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listModels.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listModels with error', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.ListModelsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ListModelsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listModels.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listModelsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.retail.v2beta.IModel[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listModels.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listModels.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('attributesConfig', () => { - const fakePath = "/rendered/path/attributesConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - }; - const client = new modelserviceModule.v2beta.ModelServiceClient({ - 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 modelserviceModule.v2beta.ModelServiceClient({ - 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 modelserviceModule.v2beta.ModelServiceClient({ - 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 modelserviceModule.v2beta.ModelServiceClient({ - 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('model', () => { - const fakePath = "/rendered/path/model"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - model: "modelValue", - }; - const client = new modelserviceModule.v2beta.ModelServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.modelPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.modelPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('modelPath', () => { - const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.modelPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromModelName', () => { - const result = client.matchProjectFromModelName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromModelName', () => { - const result = client.matchLocationFromModelName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromModelName', () => { - const result = client.matchCatalogFromModelName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchModelFromModelName', () => { - const result = client.matchModelFromModelName(fakePath); - assert.strictEqual(result, "modelValue"); - assert((client.pathTemplates.modelPathTemplate.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 modelserviceModule.v2beta.ModelServiceClient({ - 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 modelserviceModule.v2beta.ModelServiceClient({ - 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/google-cloud-retail/v2beta/test/gapic_prediction_service_v2beta.ts b/owl-bot-staging/google-cloud-retail/v2beta/test/gapic_prediction_service_v2beta.ts deleted file mode 100644 index 22417c9549c..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/test/gapic_prediction_service_v2beta.ts +++ /dev/null @@ -1,1064 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This 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, operationsProtos, LocationProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function 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.PredictionServiceClient', () => { - describe('Common methods', () => { - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.PredictRequest', ['placement']); - request.placement = defaultValue1; - const expectedHeaderRequestParams = `placement=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.predict as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.predict as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.PredictRequest', ['placement']); - request.placement = defaultValue1; - const expectedHeaderRequestParams = `placement=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.predict as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.predict as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.PredictRequest', ['placement']); - request.placement = defaultValue1; - const expectedHeaderRequestParams = `placement=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.predict = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.predict(request), expectedError); - const actualRequest = (client.innerApiCalls.predict as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.predict as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.PredictRequest', ['placement']); - request.placement = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.predict(request), expectedError); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('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('model', () => { - const fakePath = "/rendered/path/model"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - model: "modelValue", - }; - const client = new predictionserviceModule.v2beta.PredictionServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.modelPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.modelPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('modelPath', () => { - const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.modelPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromModelName', () => { - const result = client.matchProjectFromModelName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromModelName', () => { - const result = client.matchLocationFromModelName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromModelName', () => { - const result = client.matchCatalogFromModelName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchModelFromModelName', () => { - const result = client.matchModelFromModelName(fakePath); - assert.strictEqual(result, "modelValue"); - assert((client.pathTemplates.modelPathTemplate.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/google-cloud-retail/v2beta/test/gapic_product_service_v2beta.ts b/owl-bot-staging/google-cloud-retail/v2beta/test/gapic_product_service_v2beta.ts deleted file mode 100644 index c0863b36007..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/test/gapic_product_service_v2beta.ts +++ /dev/null @@ -1,2662 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This 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, LocationProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v2beta.ProductServiceClient', () => { - describe('Common methods', () => { - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.CreateProductRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProduct without error using callback', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.CreateProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.CreateProductRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProduct with error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.CreateProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.CreateProductRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createProduct(request), expectedError); - const actualRequest = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProduct with closed client', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.CreateProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.CreateProductRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createProduct(request), expectedError); - }); - }); - - describe('getProduct', () => { - it('invokes getProduct without error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.GetProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.GetProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProduct without error using callback', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.GetProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.GetProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProduct with error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.GetProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.GetProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getProduct(request), expectedError); - const actualRequest = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProduct with closed client', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.GetProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.GetProductRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getProduct(request), expectedError); - }); - }); - - describe('updateProduct', () => { - it('invokes updateProduct without error', async () => { - const client = new 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateProductRequest', ['product', 'name']); - request.product.name = defaultValue1; - const expectedHeaderRequestParams = `product.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProduct without error using callback', async () => { - const client = new 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateProductRequest', ['product', 'name']); - request.product.name = defaultValue1; - const expectedHeaderRequestParams = `product.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProduct with error', async () => { - const client = new 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateProductRequest', ['product', 'name']); - request.product.name = defaultValue1; - const expectedHeaderRequestParams = `product.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateProduct(request), expectedError); - const actualRequest = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateProduct with closed client', async () => { - const client = new 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateProductRequest', ['product', 'name']); - request.product.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateProduct(request), expectedError); - }); - }); - - describe('deleteProduct', () => { - it('invokes deleteProduct without error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.DeleteProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.DeleteProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteProduct = stubSimpleCall(expectedResponse); - const [response] = await client.deleteProduct(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProduct without error using callback', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.DeleteProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.DeleteProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteProduct( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProduct with error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.DeleteProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.DeleteProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteProduct(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProduct with closed client', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.DeleteProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.DeleteProductRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteProduct(request), expectedError); - }); - }); - - describe('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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ImportProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.importProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ImportProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.importProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ImportProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importProducts = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importProducts(request), expectedError); - const actualRequest = (client.innerApiCalls.importProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ImportProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importProducts = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importProducts(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.importProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.SetInventoryRequest', ['inventory', 'name']); - request.inventory.name = defaultValue1; - const expectedHeaderRequestParams = `inventory.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.setInventory as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInventory as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.SetInventoryRequest', ['inventory', 'name']); - request.inventory.name = defaultValue1; - const expectedHeaderRequestParams = `inventory.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.setInventory as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInventory as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.SetInventoryRequest', ['inventory', 'name']); - request.inventory.name = defaultValue1; - const expectedHeaderRequestParams = `inventory.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.setInventory = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.setInventory(request), expectedError); - const actualRequest = (client.innerApiCalls.setInventory as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInventory as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.SetInventoryRequest', ['inventory', 'name']); - request.inventory.name = defaultValue1; - const expectedHeaderRequestParams = `inventory.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.setInventory = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.setInventory(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.setInventory as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setInventory as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.AddFulfillmentPlacesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.AddFulfillmentPlacesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.AddFulfillmentPlacesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.addFulfillmentPlaces(request), expectedError); - const actualRequest = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.AddFulfillmentPlacesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.addFulfillmentPlaces = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.addFulfillmentPlaces(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addFulfillmentPlaces as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.removeFulfillmentPlaces(request), expectedError); - const actualRequest = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.RemoveFulfillmentPlacesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.removeFulfillmentPlaces = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.removeFulfillmentPlaces(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeFulfillmentPlaces as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.AddLocalInventoriesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.addLocalInventories as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addLocalInventories as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.AddLocalInventoriesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.addLocalInventories as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addLocalInventories as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.AddLocalInventoriesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.addLocalInventories = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.addLocalInventories(request), expectedError); - const actualRequest = (client.innerApiCalls.addLocalInventories as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addLocalInventories as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.AddLocalInventoriesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.addLocalInventories = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.addLocalInventories(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.addLocalInventories as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addLocalInventories as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.RemoveLocalInventoriesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.removeLocalInventories as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeLocalInventories as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.RemoveLocalInventoriesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.removeLocalInventories as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeLocalInventories as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.RemoveLocalInventoriesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.removeLocalInventories = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.removeLocalInventories(request), expectedError); - const actualRequest = (client.innerApiCalls.removeLocalInventories as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeLocalInventories as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.RemoveLocalInventoriesRequest', ['product']); - request.product = defaultValue1; - const expectedHeaderRequestParams = `product=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.removeLocalInventories = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.removeLocalInventories(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.removeLocalInventories as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeLocalInventories as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProducts without error using callback', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProducts with error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listProducts = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProducts(request), expectedError); - const actualRequest = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProductsStream without error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listProductsStream with error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProducts.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProductsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.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( - (client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProducts without error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProducts with error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.retail.v2beta.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProductsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.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( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('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('model', () => { - const fakePath = "/rendered/path/model"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - model: "modelValue", - }; - const client = new productserviceModule.v2beta.ProductServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.modelPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.modelPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('modelPath', () => { - const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.modelPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromModelName', () => { - const result = client.matchProjectFromModelName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromModelName', () => { - const result = client.matchLocationFromModelName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromModelName', () => { - const result = client.matchCatalogFromModelName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchModelFromModelName', () => { - const result = client.matchModelFromModelName(fakePath); - assert.strictEqual(result, "modelValue"); - assert((client.pathTemplates.modelPathTemplate.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/google-cloud-retail/v2beta/test/gapic_search_service_v2beta.ts b/owl-bot-staging/google-cloud-retail/v2beta/test/gapic_search_service_v2beta.ts deleted file mode 100644 index 38621620329..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/test/gapic_search_service_v2beta.ts +++ /dev/null @@ -1,1336 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This 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, operationsProtos, LocationProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function 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', () => { - describe('Common methods', () => { - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.SearchRequest', ['placement']); - request.placement = defaultValue1; - const expectedHeaderRequestParams = `placement=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.search as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.search as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.SearchRequest', ['placement']); - request.placement = defaultValue1; - const expectedHeaderRequestParams = `placement=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.search as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.search as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.SearchRequest', ['placement']); - request.placement = defaultValue1; - const expectedHeaderRequestParams = `placement=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.search = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.search(request), expectedError); - const actualRequest = (client.innerApiCalls.search as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.search as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.SearchRequest', ['placement']); - request.placement = defaultValue1; - const expectedHeaderRequestParams = `placement=${defaultValue1}`; - 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( - (client.descriptors.page.search.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.SearchRequest', ['placement']); - request.placement = defaultValue1; - const expectedHeaderRequestParams = `placement=${defaultValue1}`; - 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( - (client.descriptors.page.search.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.SearchRequest', ['placement']); - request.placement = defaultValue1; - const expectedHeaderRequestParams = `placement=${defaultValue1}`; - 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( - (client.descriptors.page.search.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.SearchRequest', ['placement']); - request.placement = defaultValue1; - const expectedHeaderRequestParams = `placement=${defaultValue1}`; - 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( - (client.descriptors.page.search.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('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('experiment', () => { - const fakePath = "/rendered/path/experiment"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - experiment: "experimentValue", - }; - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.experimentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.experimentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('experimentPath', () => { - const result = client.experimentPath("projectValue", "locationValue", "catalogValue", "experimentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.experimentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromExperimentName', () => { - const result = client.matchProjectFromExperimentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.experimentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromExperimentName', () => { - const result = client.matchLocationFromExperimentName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.experimentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromExperimentName', () => { - const result = client.matchCatalogFromExperimentName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.experimentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchExperimentFromExperimentName', () => { - const result = client.matchExperimentFromExperimentName(fakePath); - assert.strictEqual(result, "experimentValue"); - assert((client.pathTemplates.experimentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('model', () => { - const fakePath = "/rendered/path/model"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - model: "modelValue", - }; - const client = new searchserviceModule.v2beta.SearchServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.modelPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.modelPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('modelPath', () => { - const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.modelPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromModelName', () => { - const result = client.matchProjectFromModelName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromModelName', () => { - const result = client.matchLocationFromModelName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromModelName', () => { - const result = client.matchCatalogFromModelName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchModelFromModelName', () => { - const result = client.matchModelFromModelName(fakePath); - assert.strictEqual(result, "modelValue"); - assert((client.pathTemplates.modelPathTemplate.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/google-cloud-retail/v2beta/test/gapic_serving_config_service_v2beta.ts b/owl-bot-staging/google-cloud-retail/v2beta/test/gapic_serving_config_service_v2beta.ts deleted file mode 100644 index 7340f88515e..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/test/gapic_serving_config_service_v2beta.ts +++ /dev/null @@ -1,1880 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This 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, operationsProtos, LocationProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function 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', () => { - describe('Common methods', () => { - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.CreateServingConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.createServingConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createServingConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.CreateServingConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.createServingConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createServingConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.CreateServingConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.createServingConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createServingConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.createServingConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createServingConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.CreateServingConfigRequest', ['parent']); - request.parent = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.DeleteServingConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteServingConfig = stubSimpleCall(expectedResponse); - const [response] = await client.deleteServingConfig(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteServingConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteServingConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.DeleteServingConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.deleteServingConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteServingConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.DeleteServingConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteServingConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteServingConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteServingConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteServingConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.DeleteServingConfigRequest', ['name']); - request.name = defaultValue1; - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateServingConfigRequest', ['servingConfig', 'name']); - request.servingConfig.name = defaultValue1; - const expectedHeaderRequestParams = `serving_config.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.updateServingConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateServingConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateServingConfigRequest', ['servingConfig', 'name']); - request.servingConfig.name = defaultValue1; - const expectedHeaderRequestParams = `serving_config.name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.updateServingConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateServingConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateServingConfigRequest', ['servingConfig', 'name']); - request.servingConfig.name = defaultValue1; - const expectedHeaderRequestParams = `serving_config.name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateServingConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateServingConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.updateServingConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateServingConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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 ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.UpdateServingConfigRequest', ['servingConfig', 'name']); - request.servingConfig.name = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.GetServingConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getServingConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getServingConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.GetServingConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.getServingConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getServingConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.GetServingConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.getServingConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getServingConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.getServingConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getServingConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.GetServingConfigRequest', ['name']); - request.name = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.AddControlRequest', ['servingConfig']); - request.servingConfig = defaultValue1; - const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.addControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.AddControlRequest', ['servingConfig']); - request.servingConfig = defaultValue1; - const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.addControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.AddControlRequest', ['servingConfig']); - request.servingConfig = defaultValue1; - const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.addControl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.addControl(request), expectedError); - const actualRequest = (client.innerApiCalls.addControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.AddControlRequest', ['servingConfig']); - request.servingConfig = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.RemoveControlRequest', ['servingConfig']); - request.servingConfig = defaultValue1; - const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.removeControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.RemoveControlRequest', ['servingConfig']); - request.servingConfig = defaultValue1; - const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.removeControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.RemoveControlRequest', ['servingConfig']); - request.servingConfig = defaultValue1; - const expectedHeaderRequestParams = `serving_config=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.removeControl = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.removeControl(request), expectedError); - const actualRequest = (client.innerApiCalls.removeControl as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removeControl as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.RemoveControlRequest', ['servingConfig']); - request.servingConfig = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ListServingConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.listServingConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServingConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ListServingConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`;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); - const actualRequest = (client.innerApiCalls.listServingConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServingConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ListServingConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.listServingConfigs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listServingConfigs(request), expectedError); - const actualRequest = (client.innerApiCalls.listServingConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServingConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ListServingConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listServingConfigs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ListServingConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listServingConfigs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ListServingConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ListServingConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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( - (client.descriptors.page.listServingConfigs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('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('model', () => { - const fakePath = "/rendered/path/model"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - model: "modelValue", - }; - const client = new servingconfigserviceModule.v2beta.ServingConfigServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.modelPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.modelPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('modelPath', () => { - const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.modelPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromModelName', () => { - const result = client.matchProjectFromModelName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromModelName', () => { - const result = client.matchLocationFromModelName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromModelName', () => { - const result = client.matchCatalogFromModelName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchModelFromModelName', () => { - const result = client.matchModelFromModelName(fakePath); - assert.strictEqual(result, "modelValue"); - assert((client.pathTemplates.modelPathTemplate.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/google-cloud-retail/v2beta/test/gapic_user_event_service_v2beta.ts b/owl-bot-staging/google-cloud-retail/v2beta/test/gapic_user_event_service_v2beta.ts deleted file mode 100644 index 5962210be60..00000000000 --- a/owl-bot-staging/google-cloud-retail/v2beta/test/gapic_user_event_service_v2beta.ts +++ /dev/null @@ -1,1650 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ** This 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, LocationProtos} from 'google-gax'; - -// Dynamically loaded proto JSON is needed to get the type information -// to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; -} - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); -} - -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); -} - -function 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.UserEventServiceClient', () => { - describe('Common methods', () => { - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.WriteUserEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.WriteUserEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.WriteUserEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.writeUserEvent = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.writeUserEvent(request), expectedError); - const actualRequest = (client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.writeUserEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.WriteUserEventRequest', ['parent']); - request.parent = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.CollectUserEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedResponse = generateSampleMessage( - new protos.google.api.HttpBody() - ); - client.innerApiCalls.collectUserEvent = stubSimpleCall(expectedResponse); - const [response] = await client.collectUserEvent(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.CollectUserEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.CollectUserEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.collectUserEvent = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.collectUserEvent(request), expectedError); - const actualRequest = (client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.collectUserEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.CollectUserEventRequest', ['parent']); - request.parent = defaultValue1; - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.PurgeUserEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.purgeUserEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeUserEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.PurgeUserEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.purgeUserEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeUserEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.PurgeUserEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.purgeUserEvents = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.purgeUserEvents(request), expectedError); - const actualRequest = (client.innerApiCalls.purgeUserEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeUserEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.PurgeUserEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.purgeUserEvents = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.purgeUserEvents(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.purgeUserEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeUserEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ImportUserEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ImportUserEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ImportUserEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importUserEvents = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importUserEvents(request), expectedError); - const actualRequest = (client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.ImportUserEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.importUserEvents = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importUserEvents(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importUserEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.RejoinUserEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.rejoinUserEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rejoinUserEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.RejoinUserEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - 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); - const actualRequest = (client.innerApiCalls.rejoinUserEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rejoinUserEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.RejoinUserEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.rejoinUserEvents(request), expectedError); - const actualRequest = (client.innerApiCalls.rejoinUserEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rejoinUserEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.retail.v2beta.RejoinUserEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1}`; - const expectedError = new Error('expected'); - client.innerApiCalls.rejoinUserEvents = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.rejoinUserEvents(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.rejoinUserEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rejoinUserEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - 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('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('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('model', () => { - const fakePath = "/rendered/path/model"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - catalog: "catalogValue", - model: "modelValue", - }; - const client = new usereventserviceModule.v2beta.UserEventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.modelPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.modelPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('modelPath', () => { - const result = client.modelPath("projectValue", "locationValue", "catalogValue", "modelValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.modelPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromModelName', () => { - const result = client.matchProjectFromModelName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromModelName', () => { - const result = client.matchLocationFromModelName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCatalogFromModelName', () => { - const result = client.matchCatalogFromModelName(fakePath); - assert.strictEqual(result, "catalogValue"); - assert((client.pathTemplates.modelPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchModelFromModelName', () => { - const result = client.matchModelFromModelName(fakePath); - assert.strictEqual(result, "modelValue"); - assert((client.pathTemplates.modelPathTemplate.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/google-cloud-retail/v2beta/tsconfig.json b/owl-bot-staging/google-cloud-retail/v2beta/tsconfig.json deleted file mode 100644 index c78f1c884ef..00000000000 --- a/owl-bot-staging/google-cloud-retail/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/google-cloud-retail/v2beta/webpack.config.js b/owl-bot-staging/google-cloud-retail/v2beta/webpack.config.js deleted file mode 100644 index f2c58f2530c..00000000000 --- a/owl-bot-staging/google-cloud-retail/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/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/merchant_center_account_link_service.proto b/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/merchant_center_account_link_service.proto index 95e2129b6a5..93704f004c8 100644 --- a/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/merchant_center_account_link_service.proto +++ b/packages/google-cloud-retail/protos/google/cloud/retail/v2alpha/merchant_center_account_link_service.proto @@ -50,15 +50,12 @@ service MerchantCenterAccountLinkService { option (google.api.method_signature) = "parent"; } - // Creates a MerchantCenterAccountLink. - // - // [MerchantCenterAccountLink][google.cloud.retail.v2alpha.MerchantCenterAccountLink] - // cannot be set to a different oneof field, if so an INVALID_ARGUMENT is - // returned. + // Creates a + // [MerchantCenterAccountLink][google.cloud.retail.v2alpha.MerchantCenterAccountLink]. rpc CreateMerchantCenterAccountLink(CreateMerchantCenterAccountLinkRequest) returns (google.longrunning.Operation) { option (google.api.http) = { - post: "/v2alpha/{merchant_center_account_link.name=projects/*/locations/*/catalogs/*/merchantCenterAccountLinks/*}" + post: "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/merchantCenterAccountLinks" body: "merchant_center_account_link" }; option (google.api.method_signature) = @@ -69,7 +66,8 @@ service MerchantCenterAccountLinkService { }; } - // Deletes a MerchantCenterAccountLink. + // Deletes a + // [MerchantCenterAccountLink][google.cloud.retail.v2alpha.MerchantCenterAccountLink]. // If the // [MerchantCenterAccountLink][google.cloud.retail.v2alpha.MerchantCenterAccountLink] // to delete does not exist, a NOT_FOUND error is returned. diff --git a/packages/google-cloud-retail/protos/protos.json b/packages/google-cloud-retail/protos/protos.json index ad19b97d091..7dd5a117101 100644 --- a/packages/google-cloud-retail/protos/protos.json +++ b/packages/google-cloud-retail/protos/protos.json @@ -7813,7 +7813,7 @@ "requestType": "CreateMerchantCenterAccountLinkRequest", "responseType": "google.longrunning.Operation", "options": { - "(google.api.http).post": "/v2alpha/{merchant_center_account_link.name=projects/*/locations/*/catalogs/*/merchantCenterAccountLinks/*}", + "(google.api.http).post": "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/merchantCenterAccountLinks", "(google.api.http).body": "merchant_center_account_link", "(google.api.method_signature)": "parent,merchant_center_account_link", "(google.longrunning.operation_info).response_type": "google.cloud.retail.v2alpha.MerchantCenterAccountLink", @@ -7822,7 +7822,7 @@ "parsedOptions": [ { "(google.api.http)": { - "post": "/v2alpha/{merchant_center_account_link.name=projects/*/locations/*/catalogs/*/merchantCenterAccountLinks/*}", + "post": "/v2alpha/{parent=projects/*/locations/*/catalogs/*}/merchantCenterAccountLinks", "body": "merchant_center_account_link" } }, diff --git a/packages/google-cloud-retail/samples/generated/v2/snippet_metadata.google.cloud.retail.v2.json b/packages/google-cloud-retail/samples/generated/v2/snippet_metadata.google.cloud.retail.v2.json index e8cfada75d5..42e03aa5c20 100644 --- a/packages/google-cloud-retail/samples/generated/v2/snippet_metadata.google.cloud.retail.v2.json +++ b/packages/google-cloud-retail/samples/generated/v2/snippet_metadata.google.cloud.retail.v2.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-retail", - "version": "2.3.1", + "version": "2.4.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-retail/samples/generated/v2alpha/snippet_metadata.google.cloud.retail.v2alpha.json b/packages/google-cloud-retail/samples/generated/v2alpha/snippet_metadata.google.cloud.retail.v2alpha.json index 16c1707767d..c3f479e2211 100644 --- a/packages/google-cloud-retail/samples/generated/v2alpha/snippet_metadata.google.cloud.retail.v2alpha.json +++ b/packages/google-cloud-retail/samples/generated/v2alpha/snippet_metadata.google.cloud.retail.v2alpha.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-retail", - "version": "2.3.1", + "version": "2.4.0", "language": "TYPESCRIPT", "apis": [ { @@ -931,7 +931,7 @@ "regionTag": "retail_v2alpha_generated_MerchantCenterAccountLinkService_CreateMerchantCenterAccountLink_async", "title": "CatalogService createMerchantCenterAccountLink Sample", "origin": "API_DEFINITION", - "description": " Creates a MerchantCenterAccountLink. [MerchantCenterAccountLink][google.cloud.retail.v2alpha.MerchantCenterAccountLink] cannot be set to a different oneof field, if so an INVALID_ARGUMENT is returned.", + "description": " Creates a [MerchantCenterAccountLink][google.cloud.retail.v2alpha.MerchantCenterAccountLink].", "canonical": true, "file": "merchant_center_account_link_service.create_merchant_center_account_link.js", "language": "JAVASCRIPT", @@ -975,7 +975,7 @@ "regionTag": "retail_v2alpha_generated_MerchantCenterAccountLinkService_DeleteMerchantCenterAccountLink_async", "title": "CatalogService deleteMerchantCenterAccountLink Sample", "origin": "API_DEFINITION", - "description": " Deletes a MerchantCenterAccountLink. If the [MerchantCenterAccountLink][google.cloud.retail.v2alpha.MerchantCenterAccountLink] to delete does not exist, a NOT_FOUND error is returned.", + "description": " Deletes a [MerchantCenterAccountLink][google.cloud.retail.v2alpha.MerchantCenterAccountLink]. If the [MerchantCenterAccountLink][google.cloud.retail.v2alpha.MerchantCenterAccountLink] to delete does not exist, a NOT_FOUND error is returned.", "canonical": true, "file": "merchant_center_account_link_service.delete_merchant_center_account_link.js", "language": "JAVASCRIPT", diff --git a/packages/google-cloud-retail/samples/generated/v2beta/snippet_metadata.google.cloud.retail.v2beta.json b/packages/google-cloud-retail/samples/generated/v2beta/snippet_metadata.google.cloud.retail.v2beta.json index ca04e9dd44e..780c030c96c 100644 --- a/packages/google-cloud-retail/samples/generated/v2beta/snippet_metadata.google.cloud.retail.v2beta.json +++ b/packages/google-cloud-retail/samples/generated/v2beta/snippet_metadata.google.cloud.retail.v2beta.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-retail", - "version": "2.3.1", + "version": "2.4.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-retail/src/v2alpha/merchant_center_account_link_service_client.ts b/packages/google-cloud-retail/src/v2alpha/merchant_center_account_link_service_client.ts index 8120cb5bc03..dd5e08c253a 100644 --- a/packages/google-cloud-retail/src/v2alpha/merchant_center_account_link_service_client.ts +++ b/packages/google-cloud-retail/src/v2alpha/merchant_center_account_link_service_client.ts @@ -514,7 +514,8 @@ export class MerchantCenterAccountLinkServiceClient { ); } /** - * Deletes a MerchantCenterAccountLink. + * Deletes a + * {@link google.cloud.retail.v2alpha.MerchantCenterAccountLink|MerchantCenterAccountLink}. * If the * {@link google.cloud.retail.v2alpha.MerchantCenterAccountLink|MerchantCenterAccountLink} * to delete does not exist, a NOT_FOUND error is returned. @@ -620,11 +621,8 @@ export class MerchantCenterAccountLinkServiceClient { } /** - * Creates a MerchantCenterAccountLink. - * - * {@link google.cloud.retail.v2alpha.MerchantCenterAccountLink|MerchantCenterAccountLink} - * cannot be set to a different oneof field, if so an INVALID_ARGUMENT is - * returned. + * Creates a + * {@link google.cloud.retail.v2alpha.MerchantCenterAccountLink|MerchantCenterAccountLink}. * * @param {Object} request * The request object that will be sent. @@ -732,8 +730,7 @@ export class MerchantCenterAccountLinkServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'merchant_center_account_link.name': - request.merchantCenterAccountLink!.name ?? '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createMerchantCenterAccountLink( diff --git a/packages/google-cloud-retail/test/gapic_merchant_center_account_link_service_v2alpha.ts b/packages/google-cloud-retail/test/gapic_merchant_center_account_link_service_v2alpha.ts index 189b19eee65..dac5ded8dd5 100644 --- a/packages/google-cloud-retail/test/gapic_merchant_center_account_link_service_v2alpha.ts +++ b/packages/google-cloud-retail/test/gapic_merchant_center_account_link_service_v2alpha.ts @@ -564,13 +564,12 @@ describe('v2alpha.MerchantCenterAccountLinkServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.retail.v2alpha.CreateMerchantCenterAccountLinkRequest() ); - request.merchantCenterAccountLink ??= {}; const defaultValue1 = getTypeDefaultValue( '.google.cloud.retail.v2alpha.CreateMerchantCenterAccountLinkRequest', - ['merchantCenterAccountLink', 'name'] + ['parent'] ); - request.merchantCenterAccountLink.name = defaultValue1; - const expectedHeaderRequestParams = `merchant_center_account_link.name=${defaultValue1}`; + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -601,13 +600,12 @@ describe('v2alpha.MerchantCenterAccountLinkServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.retail.v2alpha.CreateMerchantCenterAccountLinkRequest() ); - request.merchantCenterAccountLink ??= {}; const defaultValue1 = getTypeDefaultValue( '.google.cloud.retail.v2alpha.CreateMerchantCenterAccountLinkRequest', - ['merchantCenterAccountLink', 'name'] + ['parent'] ); - request.merchantCenterAccountLink.name = defaultValue1; - const expectedHeaderRequestParams = `merchant_center_account_link.name=${defaultValue1}`; + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -659,13 +657,12 @@ describe('v2alpha.MerchantCenterAccountLinkServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.retail.v2alpha.CreateMerchantCenterAccountLinkRequest() ); - request.merchantCenterAccountLink ??= {}; const defaultValue1 = getTypeDefaultValue( '.google.cloud.retail.v2alpha.CreateMerchantCenterAccountLinkRequest', - ['merchantCenterAccountLink', 'name'] + ['parent'] ); - request.merchantCenterAccountLink.name = defaultValue1; - const expectedHeaderRequestParams = `merchant_center_account_link.name=${defaultValue1}`; + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createMerchantCenterAccountLink = stubLongRunningCall(undefined, expectedError); @@ -695,13 +692,12 @@ describe('v2alpha.MerchantCenterAccountLinkServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.retail.v2alpha.CreateMerchantCenterAccountLinkRequest() ); - request.merchantCenterAccountLink ??= {}; const defaultValue1 = getTypeDefaultValue( '.google.cloud.retail.v2alpha.CreateMerchantCenterAccountLinkRequest', - ['merchantCenterAccountLink', 'name'] + ['parent'] ); - request.merchantCenterAccountLink.name = defaultValue1; - const expectedHeaderRequestParams = `merchant_center_account_link.name=${defaultValue1}`; + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createMerchantCenterAccountLink = stubLongRunningCall(undefined, undefined, expectedError);